Different ways to make a query that performs an SQL join

Question:

I learned how to do SQL queries with joins like this:

SELECT u.NOME, e.RUA 
FROM usuarios u, endereco e 
WHERE e.ID_USUARIO = u.ID 
ORDER BY u.NOME 

As you can see, the query searches the users name and the street address (using nicknames to simplify the table names). About the way this query was structured, the questions are as follows:

  • Is this a simplified way to do joins by not explicitly using JOIN, LEFT ON and type statements?

  • What would the same query look like using the join statements explicitly?

Answer:

Is this a simplified way to do joins by not explicitly using JOIN, LEFT ON and type statements?

I wouldn't say a "simplified" way, I would say an "alternative" way to make INNER join, because doing left / right / full outer would be more work.

I particularly prefer to join using the keyword, as it separates join conditions from query conditions. Basically: the leaves join do the job join and leave the " where " doing work " where "

What would the same query look like using the join statements explicitly?

SELECT u.NOME, e.RUA
FROM usuarios u
INNER JOIN endereco e ON e.ID_USUARIO = u.ID
ORDER BY u.NOME 
Scroll to Top