php - MySQL select where constant is in array in table -


this question has answer here:

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

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -