i have tables tbl_restaurant(name,cuisine_id,....) and tbl_cuisine(cuisine_id,cuisine_name)
In tbl_restaurant, cuisine_id field contain comma(,) separated values like (3,6,9,20,31) and when i try to pull cuisine_name using join it only takes first id (i.e: 3) in above case. I had a query:
SELECT tbl_restaurant.name, tbl_restaurant.cuisine_id, tbl_cuisine.cuisine_id,
tbl_cuisine.cuisine_name
FROM tbl_restaurant
LEFT JOIN tbl_cuisine ON tbl_restaurant.cuisine_id = tbl_cuisine.cuisine_id
WHERE tbl_restaurant.published =1
AND tbl_restaurant.id =$id
shall i parse before using join or else? any suggestion please.
You can use FIND_IN_SET() function to join two tables.
Try this:
Check the SQL FIDDLE DEMO
OUTPUT