I have a table and it looks like this,
mysql> select * from match_info;
+---------------+---------+------------+-------------+-----------+
| match_info_id | user_id | body_types | hair_colors | ethnicity |
+---------------+---------+------------+-------------+-----------+
| 1 | 1 | 1,5,9,13 | 1,5,9,13 | 2,6,10 |
| 2 | 2 | 1,5,9,13 | 5 | 1,5,9 |
+---------------+---------+------------+-------------+-----------+
I have used lookup tables for body_types
, hair_colors
and ethnicity
with id
and name
columns in each table.
Using above I need to select all values for particular user. Like this.
From body_type table.
Body Type: Skinny, Muscular, Large, Ripped
Hair Color: Blonde, Dark Brown, Strawberry Blonde, Dark Blonde
etc....
Can anybody tell me how I make a select query to get result as above.
Hope somebody may help me out.
Thank you.
You can join the tables and put
find_in_set
function at on clause. Try this :Please note that you can use
left join
instead ofinner join
depending on your needs.