Sajjad Aims Sajjad Aims - 7 months ago 12
SQL Question

join two tables and select a row using foreign key sql query

I have two tables table1 is cities table and table2 is Country, I am using the querry

"SELECT * FROM citiesTable WHERE cityName LIKE 'F%' LIMIT 30"
Each cityName have their respective country joined with foreign key in country table
i want to select each city with and their respective country Like Fayzabad , Afghanistan. which query i should use please mention must since i am new to sql

Answer

Use join query

SELECT * FROM citiesTable,country WHERE country.country_id = citiesTable.country_id and cityName LIKE 'F%' LIMIT 30 
Comments