i am trying to get all the names of the restaurants in a city.
i have 3 tables:
1. countries -> list of countries in 4 languages (each country has the same id in the different languages)
id | country_id | name | lang
2. cities-> list of all cities in 4 languages (each city is associated with the country_id and has the same id for the different languages)
id | country_id | city_id | name | lang
3. restaurants-> list of all restaurants in the different countries (each restaurant has associated the country_id and the city_id)
id | country_id | city_id | name
ok what i want is to get all the names of the restaurants in a city
i did this:
i pass these two variables $country and $city
Expand|Select|Wrap|Line Numbers
- "SELECT co.country_id, ci.city_id, p.name
- FROM countries co, cities ci, premises p
- WHERE co.name = '$country' AND
- ci.name = '$city' AND
- ci.country_id = co.country_id AND
- p.city_id = ci.city_id";
i have to use all these ids because of the languages
should i use a subquery instead?
thankyou very much