模糊查詢的時候為什么不能兩個字段一起查
??<select?id="queryMessageList"?parameterType="com.imooc.bean.Message"?resultMap="MessageResult">
????select?ID,COMMAND,DESCRIPTION,CONTENT?from?MESSAGE
????<where>
???? <if?test="command?!=?null?and?!"".equals(command.trim())">
???? and?COMMAND=#{command}
????</if>
????<if?test="description?!=?null?and?!"".equals(description.trim())">
???? and?DESCRIPTION?like?'%'?#{description}?'%'
????</if>
????</where>
??</select>command 等于號改改成了 ?like + % ? 為什么就是查不到結果 ?
DESCRIPTION 一直就可以啊 ? 而且debug調試的時候都有值的
2017-08-03
?'%' _#{description}_ '%',這一段里面的_換成空格
2017-05-28
可以啊,我試過能模糊查詢指令
<select id="queryMessageList" parameterType="icoom.bean.Message"
resultMap="MessageResult">
select ID,COMMAND,DESCRIPTION,CONTENT FROM message where 1= 1
?<if test="command != null and !"".equals(command.trim())">
and COMMAND like '%' #{command}
?</if>
?<if test="description != null and !"".equals(description.trim())">
and DESCRIPTION like '%' #{description}
?</if>
</select>?
2017-05-27
改成這樣command就查不到了,DESCRIPTION 還是可以查的
?<select?id="queryMessageList"?parameterType="com.imooc.bean.Message"?resultMap="MessageResult"> ????select?ID,COMMAND,DESCRIPTION,CONTENT?from?MESSAGE ????<where> ????????<if?test="command?!=?null?and?!"".equals(command.trim())"> ????????????and?COMMAND?like?'%'?#{command}?'%' ????????</if> ????????<if?test="description?!=?null?and?!"".equals(description.trim())"> ????????????and?DESCRIPTION?like?'%'?#{description}?'%' ????????</if> ????</where> ??</select>