I have three tables in restaurant search done in php. The search has option to filter it by multiple type by checkbox state. Some restaurant may come under multiple type and will have multiple entry in type_stack table.
Table1 - **restaurant**
------+----------+----------
id + name + place
------+----------+----------
1 rest1 ny
2 rest2 la
3 rest3 ph
4 rest4 mlp
Table2 - **r_type**
------+----------+----------
id + name + code
------+----------+----------
1 type1 0
2 type2 1
3 type3 2
4 type4 3
Table3 - **type_stack**
------+----------+----------
id + rest_id + type
------+----------+----------
1 2 2
2 4 1
3 1 2
I want to get all the restaurants that qualify under the types user have selected. But the problem is 1'm getting the same restaurant multiple times. I only want a row to be shown one time.
This is my query
SELECT restaurant.name, restaurant.place FROM restaurant, type_stack WHERE restaurant.id = type_stack.rest_id AND type_stack.type = '0' AND type_stack.type = '1' AND type_stack.type = '2' LIMIT 0 , 30
The query is made based on checkbox state! In this case type 0, 1 and 2 are selected.