一:查询大于一条的数据
select
xxx,xxx,count(*)
from
T_ACCT_INFO a
group by xxx,xxx
having count(*)>1
二:like语句
<if test= "X.xxx !=null and X.xxx != ''">
AND x_x_x LIKE CONCAT(CONCAT('%',#{X.xxx }),'%')
</if>
三:日期转换比较
<if test="X.xxx != null and X.xxx != ''">
AND <![CDATA[ TO_CHAR(x_x_x,'yyyy-MM-dd') >= #{X.xxx}]]>
</if>
四:forEach循环
1)循环数据
<if test="X.xxx == "0" or X.xxx == null">
AND x_x_x IN
<foreach collection="X.xxx" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
2)循环对象 链接对象为OR
<if test="X.xxx!=null and X.xxx.size()>0">
AND
<foreach collection="X.xxx" index="index" item="item" open="(" separator=" OR " close=")">
(
x_x_x = #{item.xx}
and
x_x_x = #{item.xx}
and
x_x_x = #{item.xx}
)
</foreach>
</if>
五:case when
case when x_x_x = #{X.xxx} then 1 else null end
sql小计,查询大于一条,日期转换比较,forEach循环,case when
最新推荐文章于 2025-03-10 16:25:53 发布