I have one column having comma separated values:
id Column_name
== ==========
1 value1,value2,value3,value5
2 value2,value3,value4
3 value1,value3,value5
4 value1,value2,value4,value5
Now, I want a query that get all records having value2
OR value4
I need query like below if possible:
SELECT * FROM table_name WHERE FIND_IN_SET('value2,value4',`column_name`)
So, it will return recode with id 1,2,4
(having value2
or value4
)
I have form for user that send value1,value2 ..etc
from check_box
How can I optimize my select Query?
Use it like this
SELECT * FROM table_name
WHERE FIND_IN_SET('value2',column_name) > 0
or FIND_IN_SET('value4',column_name) > 0
You should actually rather change your DB structure to something like this
your_table
----------
id
name
other_columns
values table
------------
your_table_id
value
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.