一個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. docker鏡像push報錯2. angular.js - angular內容過長展開收起效果3. angular.js - angularjs的自定義過濾器如何給文字加顏色?4. python 怎樣用pickle保存類的實例?5. python的前景到底有大?如果不考慮數據挖掘,機器學習這塊?6. MySQL中無法修改字段名的疑問7. javascript - 微信小程序限制加載個數8. 大家好,請問在python腳本中怎么用virtualenv激活指定的環境?9. linux - 升級到Python3.6后GDB無法正常運行?10. 并發模型 - python將進程池放在裝飾器里為什么不生效也沒報錯
