数据如下:
id col
1 a,b,d
2 a,b,c
我的查询条件:
col=(a,b) 要求查到id为1,2的两行
col=(a,d) 查到id为1的行
col=(a,c) 查到id为2的行
col=(a) 查到id为1,2的两行
请教下大家有没有什么方法呢?
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
以第一个为例。
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)