Hi
There are two tables.
Cities and Countries
Countries have Id, Country name and Short Code (Id is primary key)
Cities have Country_Short_Code, City and Populations. (city is indexed)
There are 5000 records maximum to be processed.
PHP will give 5000 city name and its country.
What is the best way to write a query?
select population from cities inner join countries where (country_name = 'cname' and city = 'city') or (country_name = 'cname' and city = 'city') or ( .. repeating for 5000 times)
To get those 5000 records in single query. It is slower.
OR
foreach($locations as $loc) {
select population from cities inner join countries where (country_name = 'cname' and city = 'city')
}
5000 different queries on foreach loop.
Which is the best way to achieve this?