目錄
大于小于
if 條件判斷?
for循環(huán)
LIKE?模糊搜索
case when
choose選擇語句
前言-與正文無關(guān)
????????生活遠(yuǎn)不止眼前的苦勞與奔波,它還充滿了無數(shù)值得我們?nèi)ンw驗和珍惜的美好事物。在這個快節(jié)奏的世界中,我們往往容易陷入工作的漩渦,忘記了停下腳步,感受周圍的世界。讓我們一起提醒自己,要適時放慢腳步,欣賞生活中的每一道風(fēng)景,享受與家人朋友的溫馨時光,發(fā)現(xiàn)那些平凡日子里隱藏的幸福時刻。因為,這些點點滴滴匯聚起來的,才是構(gòu)成我們豐富多彩生活的本質(zhì)。希望每個人都能在繁忙的生活中找到自己的快樂之源,不僅僅為了生存而工作,更為了更好的生活而生活。
????????送你張美圖!希望你開心!????????
大于小于
方法1:?> 大于 ,?< 小于
<if test="startTime != null ">
and a.create_time >= #{startTime}
</if>
<if test="endTime != null ">
and a.create_time <= #{endTime}
</if>
方法2(建議寫這個):?
在idea輸入CD應(yīng)該就自動出來了
if 條件判斷?
<if test="deviceId != null and deviceId != '' ">
and a.device_id = #{deviceId}
</if>
for循環(huán)
<if test="partsIdList != null ">
and b.id in
<foreach item="item" index="index" collection="partsIdList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
LIKE?模糊搜索
<if test='phone!=null and phone!=""' >
where b.phone LIKE concat('%',#{phone},'%')
</if>
<if test="dataRole == 0">
AND pn.org_code LIKE CONCAT(#{orgCode},'%')
</if>
case when
choose選擇語句
滿足when條件走when,否則執(zhí)行otherwise?
<choose>
<when test="dto!=null and dto.dataRole='0'">
AND i.org_code like concat(#{dto.orgCode},'%')
</when>
<otherwise>
AND i.org_code = #{dto.orgCode}
</otherwise>
</choose>
------------------------------------------與正文內(nèi)容無關(guān)------------------------------------
如果覺的文章寫對各位讀者老爺們有幫助的話,麻煩點贊加關(guān)注唄!作者在這拜謝了!
混口飯吃了!如果你需要Java 、Python畢設(shè)、商務(wù)合作、技術(shù)交流、就業(yè)指導(dǎo)、技術(shù)支持度過試用期。請在關(guān)注私信我,本人看到一定馬上回復(fù)!
這是我全部文章所在目錄,看看是否有你需要的,如果遇到覺得不對地方請留言,看到后我會查閱進(jìn)行改正。
A樂神-CSDN博客
關(guān)注在文章左上角,作者信息處。文章來源:http://www.zghlxwxcb.cn/news/detail-788609.html
文章來源地址http://www.zghlxwxcb.cn/news/detail-788609.html
到了這里,關(guān)于Mybatis 常用條件語句,大于小于、if、for、模糊搜索、case when、choose的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!