mysql不包含模糊查詢問題
更新時(shí)間:2023年08月31日 09:15:21 作者:大得369
這篇文章主要介紹了mysql不包含模糊查詢問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
mysql不包含模糊查詢
#包含like #不包含not like select * from 數(shù)據(jù)庫表 where HouseName like '%江門奧園項(xiàng)目%' and HouseName like '%幢%' and HouseName not like '%商%'; #不包含not in select sum(o.PaidChargeSum) from cdj_order o where o.id not in (select d.order_id from cdj_order_detail d where d.is_canceled !=1);
mysql解決模糊查詢包含關(guān)系
后臺(tái)要根據(jù)期限篩選查詢時(shí)如果用like,
SELECT * from t_user_accord_invest t where t.invest_period like '%1%';
就會(huì)出現(xiàn) 參數(shù)為1時(shí) ,13的也能篩選出來,出現(xiàn)查詢bug。
解決方案
利用mysql 字符串函數(shù) find_in_set();
SELECT * from t_user_accord_invest t where find_in_set(1,t.invest_period);
完美避免like出現(xiàn)的問題。
mysql查詢包含4種方法
- 方法一:like
SELECT * from t_user_accord_invest t where t.invest_period like '%1%';
- 方法二:find_in_set(字符, 字段名)
SELECT * from t_user_accord_invest t where find_in_set(1,t.invest_period);
- 方法三:locate(字符,字段名)
SELECT * from t_user_accord_invest t where locate(1,t.invest_period) and t.is_use=1;
- 方法四:INSTR(字段名,字符)
SELECT * from t_user_accord_invest t where INSTR(t.invest_period,1) and t.is_use=1;
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
MYSQL拒絕訪問報(bào)錯(cuò)not allowed to connect
MYSQL拒絕訪問報(bào)錯(cuò)not allowed to connect,下面有個(gè)可行的方法,可以在其它任何的主機(jī)上以root身份登錄2014-07-07mysql 有關(guān)“InnoDB Error ib_logfile0 of different size”錯(cuò)誤
mysql 有關(guān)“InnoDB Error ib_logfile0 of different size”錯(cuò)誤的解決方法,需要的朋友可以參考下。2011-06-06