工作笔记——mybatis使用中SQL语句

<!-- 根据条件查询出工具 -->
<select id="getAllList"  resultMap="ResultMap" parameterType="java.util.Map">
SELECT mes_toolcar.name AS toolCarName,
mes_toolcar.serialNO AS toolCarSerialNo,
mes_tool.name,
mes_tool.serialNO,
mes_tool.torque,
mes_tool.validityDate,
mes_tool.status,
mes_tool.imagePath, 
mes_tool.update_date
from mes_tool, mes_toolcar
<trim prefix="WHERE" prefixOverrides="AND | OR ">--------------------------------------------------------------------<trim>标签需要深入了解一下,参考下一篇文章
mes_toolcar.serialNO = mes_tool.toolCar_serialNO and mes_tool.abandon = 0
<if test="toolCarName!=null and toolCarName!=''">
AND mes_toolcar.name = #{toolCarName}
</if>
<if test="name!=null and name!=''">
AND mes_tool.name LIKE CONCAT(CONCAT('%', #{name}),'%') ————模糊查询
</if>
<if test="serialNo!=null and serialNo!=''">
AND mes_tool.serialNO = #{serialNo}
</if>
<if test="status!=null and status!=''">
AND mes_tool.status = #{status}
</if>
<if test="torqueStart!=null and torqueStart!=''">
AND mes_tool.torque >= #{torqueStart}
</if>
<if test="torqueTo!=null and torqueTo!=''">
AND mes_tool.torque <![CDATA[<=]]> #{torqueTo}——————当有小于号时候需要对其转义处理 <![CDATA[<=]]>
</if>

<if test="validityDateStart!=null and validityDateStart!=''">
AND mes_tool.validityDate >= #{validityDateStart}
</if>
<if test="validityDateTo!=null and validityDateTo!=''">
AND mes_tool.validityDate <![CDATA[<=]]> #{validityDateTo}
</if>
</trim>
</select>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值