这里写目录标题
MyBatis的动态Sql语句
1、< if >
2、< where >
3、< foreach >
4、Sql重用
< if >
下面展示一些 内联代码片
。
<if test="params.projectName!=null and params.projectName!=''">
and p.PROJECT_NAME like '%' || #{params.projectName} || '%'
</if>
<if test="params.projectName!=null and params.projectName!=''">
and p.PROJECT_NAME like '%' || #{params.projectName} || '%'
</if>
<if test="params.deliveryTime_begin!=null and params.deliveryTime_begin!=''">
and DELIVERY_TIME >= to_date(#{params.deliveryTime_begin},'yyyy-MM-dd HH24:MI:SS')
</if>
<if test="params.deliveryTime_end!=null and params.deliveryTime_end!=''">
and <![CDATA[DELIVERY_TIME <= TO_DATE(#{params.deliveryTime_end},'yyyy-MM-dd HH24:MI:SS')]]>
</if>
< foreach >
<!-- 查询到货数量不为0的记录 -->
<select id="selectRecieveCountByMainId" parameterType="list"
resultType="int">
SELECT
count(*) as count
FROM
tdk_purchase_detail t
WHERE t.RECEIVE_COUNT != 0
AND purchase_id in
<foreach collection="mainIdList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</select>