For my real estate site I have two databases, one called 'Country' which lists all countries and their codes and another 'properties' which has all of the properties details. The properties table uses the country code from the 'Country' table (countrycode column) to state which country the property is from.
I need to create search function which just has a dropdown where you select a country. What query would I use to show a list of country names from the 'Country' table if the country code appears in the 'countrycode' column of the 'properties' table. Also each country should only display once. So the dropdown should show 2 options - United Kingdom and Turkey. Screen-shot-2012-03-13-at-16.10..png Screen-shot-2012-03-13-at-17.10..png
MySQL ServerPHP
Last Comment
BrighteyesDesign
8/22/2022 - Mon
Derokorian
SELECT DISTINCT country.name,country.code FROM properties LEFT JOIN country ON country.code = properties.country_code
Open in new window
HTH