Mybatis if标签判断大小
生活随笔
收集整理的這篇文章主要介紹了
Mybatis if标签判断大小
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1、if標(biāo)簽語(yǔ)法
<select...>SQL語(yǔ)句1<if test="條件表達(dá)式">SQL語(yǔ)句2</if> </select>注意:條件表達(dá)式中大于號(hào)小于號(hào)用?gt,lt
<if test="vane gt 0">...</if><if test="vane lt 0">...</if>
mapper xml代碼:
<select id="selectByUpdatedAt" resultMap="ResultMapWithBLOBs">select<include refid="Base_Column_List" />,<include refid="Blob_Column_List" />from products<where><if test="vane gt 0">updated_at > #{date} AND status = #{status}ORDER BY is_top desc , updated_at desc</if><if test="vane == 0">updated_at = #{date} AND status != #{status}ORDER BY is_top desc , updated_at desc</if><if test="vane lt 0">updated_at < #{date} AND status = #{status}ORDER BY is_top desc , updated_at desc</if></where></select>mapper 接口代碼:
/*** vane大于0表示大于;0表示等于;小于0表示小于;* status 商品狀態(tài)。1:在售;2:下架;3:刪除;* @param vane vane* @param date 時(shí)間* @param status 商品狀態(tài)* @return List*/List<Product> selectByUpdatedAt(@Param("vane") Integer vane,@Param("date") Date date,@Param("status") Byte status);?
總結(jié)
以上是生活随笔為你收集整理的Mybatis if标签判断大小的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: R中Factor类型选取子集
- 下一篇: JDBC编程专题9之JDBC事务