mybatis动态SQLif的test写法及规则详解


当前第2页 返回上一页

上图是官方指导的一部分,主要说明了,在test中无法使用<= 等符号可以使用 lte 代替。

运算符代替字符
<lt
<=lte
>gt
>=gte

mybatis if test动态sql语句

<select id="getStudentId" parameterType="java.lang.String" resultType="java.lang.String">
? ? ? ? SELECT MAX(Student_ID) FROM Student
? ? ? ? <where>
? ? ? ? ? ? <if test="classid !=null and classid !=''"> ?
? ? ? ? ? ? ? ? AND CLASS_ID = {student.classID}?
? ? ? ? ? ? </if>
? ? ? ? ? ? <if test="age ==null or age ==''"> ?
? ? ? ? ? ? ? ? AND AGE = {student.age}
? ? ? ? ? ? </if>
? ? ? ? </where>
</select>

以上为个人经验,希望能给大家一个参考,也希望大家多多支持。


打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...