1. 程式人生 > >電商專案之搜尋sql書寫(重點)

電商專案之搜尋sql書寫(重點)

  <select id="selectByNameAndProductId" resultMap="BaseResultMap" parameterType="map">
    select
    <include refid="Base_Column_List"></include>
    from mmall_product
    <where>
      <if test="productName!=null">
        and  name like #{productName}
      </if>
      <if test="productId!=null">
        and id=#{productId}
      </if>
    </where>
  </select>