一个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. $fields = $values = [];这条代码一直定义不了,一直报错,老师的源码也是被报错的,执行不了,请问该怎么解决这个问题2. python - 求一个在def中可以实现调用本def满足特定条件continue效果的方法(标题说不太清楚,请见题内描述)3. mysql - SQL操作时间的函数?4. MYSQL新建用户设置可以远程访问的问题5. javascript - 用表单提交两个时间段请求后台返回对应数据时出现的一些问题!6. angular.js - angularjs的自定义过滤器如何给文字加颜色?7. java - mybatis怎么实现在数据库中有就修改,没有就添加8. node.js - nodejs和前端JavaScript 字符串处理结果不一样是什么原因?9. docker api 开发的端口怎么获取?10. 正则表达式 - python pandas的sep参数问题
![$fields = $values = [];这条代码一直定义不了,一直报错,老师的源码也是被报错的,执行不了,请问该怎么解决这个问题](http://www.haobala.com/attached/image/news/202205/093622cb60.png)