Inner Joins instead of Select SQL
I am learning how you can use an inner join statement instead of a select statement to achieve the same result. For example, if you want to retrieve distinct languages spoken in Asia from a table of languages and a countries table, you can write something like:
SELECT code
FROM languages l
INNER JOIN countries c
WHERE continent = ‘Asia’
Or you can use two select statements:
SELECT l.code
FROM languages l
WHERE l.code IN
(SELECT c.code
FROM countries c
WHERE continent = ‘Asia’)
Clearly using an inner join rather than two select statements is more efficient. I believe in the first statement you do not need to specify the table since you are inner joining the tables on code. Would love to hear others thoughts on this. I am a newbie, so please forgive me if there is an error!