A MySql query problem
为情所困
为情所困 2017-05-18 10:46:37
0
2
669

Data are as follows:

id col
1 a,b,d
2 a,b,c

My query conditions:

col=(a,b) requires finding two rows with IDs 1 and 2

col=(a,d) Find the row with id 1

col=(a,c) Find the row with id 2

col=(a) Find two rows with IDs 1 and 2

Could you please tell me if you have any methods?

为情所困
为情所困

reply all(2)
大家讲道理

Take the first one as an example.

select * from tablename where find_in_set('a', col)>0 and find_in_set('b', col)>0;
阿神

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)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template