一个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 - 求赐教:网易邮箱Web端模拟登录看信的加密参数_ntes_nnid、_ntes_nuid2. css - last-child不起作用3. Spring数据mongodb审核不起作用(Java配置)4. node.js - 使用mongoose的cursor的问题5. javascript - 这里的?=和=是什么意思?6. node.js - 跳转EJS文件提示4047. 如何为每个应用程序配置tomcat 6的logs / catalina.out(为sys.out,sys.err配置Web应用程序特定的日志文件)8. h-ui模板导入报错,怎么回事呢,我是用的TP5.19. 管理员信息修改时的密码问题10. PHP自动加载报错找不到原因,求大佬帮忙看看

网公网安备