一個MySql查詢問題
問題描述
數據如下:
idcol1a,b,d 2a,b,c
我的查詢條件:
col=(a,b) 要求查到id為1,2的兩行
col=(a,d) 查到id為1的行
col=(a,c) 查到id為2的行
col=(a) 查到id為1,2的兩行
請教下大家有沒有什么方法呢?
問題解答
回答1:以第一個為例。
select * from tablename where find_in_set(’a’, col)>0 and find_in_set(’b’, col)>0;回答2:
1.SELECT * FROM test_findisset where find_in_set(’a’,col) and find_in_set(’a’,col) and find_in_set(’b’,col)
2.SELECT * FROM test_findisset where find_in_set(’a’,col) and find_in_set(’a’,col) and find_in_set(’d’,col)
3.SELECT * FROM test_findisset where find_in_set(’a’,col) and find_in_set(’a’,col) and find_in_set(’c’,col)
4.SELECT * FROM test_findisset where find_in_set(’a’,col) and find_in_set(’a’,col)
相關文章:
1. angular.js - angularjs的自定義過濾器如何給文字加顏色?2. MySQL中無法修改字段名的疑問3. javascript - 如何讓移動端網頁的輸入框固定在底部?4. angular.js - angular內容過長展開收起效果5. docker鏡像push報錯6. javascript - 微信小程序限制加載個數7. 大家好,請問在python腳本中怎么用virtualenv激活指定的環境?8. android - QQ物聯,視頻通話9. 網頁爬蟲 - 用Python3的requests庫模擬登陸Bilibili總是提示驗證碼錯誤怎么辦?10. 請教各位大佬,瀏覽器點 提交實例為什么沒有反應
