一個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. javascript - 可以DIY的頁面是如何實現的?2. mysql - SQL問個基礎例子,書上的,我怎么看都看不懂..誰幫我解釋一下第2個為什么和第1個一樣?3. python - 請問matplotlib.pyplot.save的路徑如何更改4. mysql服務無法啟動1067錯誤,誰知道正確的解決方法?5. 數據庫 - mysql boolean型無法插入true6. python - Django問題 ’WSGIRequest’ object has no attribute ’user’7. javascript - ajax 圖片文件與文本框數據一起提交上傳處理8. python - Django前臺url未能正確訪問方法求助?9. 無法遠程連接mysql10. javascript - js 對中文進行MD5加密和python結果不一樣。
