亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

模糊查詢的時候為什么不能兩個字段一起查

??<select?id="queryMessageList"?parameterType="com.imooc.bean.Message"?resultMap="MessageResult">
????select?ID,COMMAND,DESCRIPTION,CONTENT?from?MESSAGE
????<where>
????	<if?test="command?!=?null?and?!&quot;&quot;.equals(command.trim())">
	????	and?COMMAND=#{command}
	????</if>
	????<if?test="description?!=?null?and?!&quot;&quot;.equals(description.trim())">
	????	and?DESCRIPTION?like?'%'?#{description}?'%'
	????</if>
????</where>
??</select>

command 等于號改改成了 ?like + % ? 為什么就是查不到結果 ?

DESCRIPTION 一直就可以啊 ? 而且debug調試的時候都有值的

正在回答

3 回答

?'%' _#{description}_ '%',這一段里面的_換成空格

0 回復 有任何疑惑可以回復我~

可以啊,我試過能模糊查詢指令


<select id="queryMessageList" parameterType="icoom.bean.Message"

resultMap="MessageResult">

select ID,COMMAND,DESCRIPTION,CONTENT FROM message where 1= 1

?<if test="command != null and !&quot;&quot;.equals(command.trim())">

and COMMAND like '%' #{command}

?</if>

?<if test="description != null and !&quot;&quot;.equals(description.trim())">

and DESCRIPTION like '%' #{description}

?</if>

</select>?


0 回復 有任何疑惑可以回復我~

改成這樣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?!&quot;&quot;.equals(command.trim())">
????????????and?COMMAND?like?'%'?#{command}?'%'
????????</if>
????????<if?test="description?!=?null?and?!&quot;&quot;.equals(description.trim())">
????????????and?DESCRIPTION?like?'%'?#{description}?'%'
????????</if>
????</where>
??</select>


0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

模糊查詢的時候為什么不能兩個字段一起查

我要回答 關注問題
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號