php - MySQL select where constant is in array in table -
this question has answer here:
- query multiple values in column 4 answers
- can split/explode field in mysql query? 16 answers
hello stackoverflow community,
i have question regarding best method (in terms of resources/speed/etc.) find defined valued in imploded string stored in cell in database.
ie: (all elements in table either int or string)
id | age | name | groups ========================= 0 | 28 | bob | 1,2,3,4 1 | 33 | sara | 1,4 given requested group 2, best select users , iterate through groups manually see if matches 2. (which doesn't sound resourceful @ all)
or there way constant in array query via mysql
select * tableusers 2 in groups which select user id 0.
^ won't work there similar alternative?
its easy. can this:
select * tableusers find_in_set(2,groups);
Comments
Post a Comment