Loosely based on the query you posted. Imagine you have two tables: country and city
For example country holds following data:
Code:
ID | name
1 | Europe
2 | America
3 | Africa
And city holds following data: The citie's name, an internal number and the country's number it is located in.
Code:
cityid | name | continent
1 | Berlin | 1
2 | London | 1
3 | Utah | 2
Here the column "continent" references the column ID in the table continent.
If you use:
Code:
SELECT continent.name, city.name
FROM continent, city
WHERE continent.ID = city.continen;
you check where the numbers in the column "id" in table "continent" exactly match the same number in the column "continent" in the table "city".
That query would return:
Code:
Berlin Europe
London Europe
Utah America
Because the table "city" does not contain a city which is located in Africa (i.e. no 3 in the column continent) no rows for "Africa" are returned.
Bookmarks