a表
id order
1 cpio textxx
2 mkdir dfa
b表
command color
cp 藍
cpio 紅
要求查詢出a表中包含有b表中command的order資料。
我之前是這樣寫的select * from a where locate(b.command,a.order)=1本來資料都是正常的,結果當b表中出現cp和cpio這樣都包含cp的情況時,查詢結果就是:
id order
1 cpio textxx
2 cpio textxx
一條資料匹配了兩次,資料出現重復,請問有誰能幫忙解決一下
uj5u.com熱心網友回復:
b.command 后加個空格然后再匹配。uj5u.com熱心網友回復:
試了一下,沒有效果啊
uj5u.com熱心網友回復:
locate(concat (b.command,' ') ,a.order)=1估計是不知道怎么加空格。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/110851.html
標籤:MySQL
