一个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. css3 - iphone6 plus 微信浏览器下transition动画无效求破2. mysql - spring data jpa 方法sql复杂查询?3. 我在导入模板资源时遇到无法显示的问题,请老师解答下4. 微信订阅号如何用渠道二维码统计地推效果?5. 并发 - python多进程+协程的正确姿势?6. 老师,样式没有变呀?7. 想练支付宝对接和微信支付对接开发(Java),好像个人不可以,怎么弄个企业的呢?8. javascript - vuejs 如何给option 添加点击事件9. python sqlalchemy create_engine问题10. html5 - vue项目中vuex存储问题
![android - MVP模式 包的结构](http://www.haobala.com/attached/image/news/202311/095852d398.png)