|
Capitals |
Country |
Capital |
India |
New Delhi |
USA |
Washington |
France |
Paris |
|
|
Continents |
Country |
Continent |
India |
Asia |
USA |
N.America |
Italy |
Europe |
|
|
---- Low Performance using Subqueries
SELECT *
FROM Capitals cp
WHERE EXISTS (SELECT *
FROM Continents cn
WHERE cp.Country = cn.Country)
---- High Performance using Joins
SELECT Capitals.*
FROM Capitals
INNER JOIN Continents
ON Capitals.Country=Continents.Country
---- both Queries will give the same output but Performance is different, if the data is tooooo big
Output |
Country |
Capital |
India |
New Delhi |
USA |
Washington |
|