mybatis if 判断 sql语句与传入的参数做比较吗

2025-03-23 07:12:31
推荐回答(1个)
回答1:

相当于sql语句中的where关键字。
这个标签还有一个功能就是自动会去掉第一个and.,比如下面两句sql代码,如果第一个满足的那么就会去掉and这个关键字。
-->

test="usercustom!=null">
test="usercustom.sex!=null
and
usercustom.sex!=''">
and
user.sex=
#{usercustom.sex}

test="usercustom.username!=null
and
usercustom.username!=''"
>
and
user.username=#{usercustom.username}