I have a MySQL table like this
restaurant_id restaurant_name restaurant_serving_cuisines
1 Vasantha Bhavan 4,5,6
3 Little India 7,5,6
5 Mohan Restaurants 16,2,4,1,5,3,6
6 Sri Restaurant 34,16,21,2,23,38,30,7,25,9
13 The Taco Shop 5
22 KFC 15
37 belargio 14,15,16,2,7,4,1,5,17,12,3,13,6
56 Pizza Hot 5
I need to get the restaurant which is serving the cuisine id with 5 & 15. I need to get the restaurant as belargio.
I am writing the query
SELECT restaurant_id, restaurant_name,restaurant_serving_cuisines
FROM `rt_restaurant`
WHERE restaurant_serving_cuisines REGEXP concat_ws("|", "5", "15");
But I cant get the exact result.
LIKEfunction orFIND_IN_SET. (Besides being overkill, your example has the comma separated values NOT in a specified order. You would at least need to guarantee an order for regexp to work)NORMALIZErestaurant_serving_cuisines column. Normalize can help you when you do COUNT, MAX, MIN, SORT, inserting new cuisines, update, delete and so on...