Difference between query with and without Inner Join

Asked

Viewed 68 times

4

What is the difference between doing the two queries below, one with and the other without INNER JOIN? What is the most appropriate?

SELECT p.Descricao as Produto, c.Descricao as Categoria FROM Produto p, Categoria  c
WHERE p.CategoriaId = c.CategoriaId
SELECT p.Descricao as Produto, c.Descricao as Categoria  FROM Produto p
INNER JOIN Categoria c ON p.CategoriaId = c.CategoriaId

1 answer

6


In general we can say that it is syntax only. A syntax that makes it clearer what you want to do a merge can be more interesting for readability.

It’s possible that some database mechanism does some optimization in some case that it can’t in another. It may be a disability he can not do in both cases, but can run. You have to see how this behaves in your SGDB.

And be aware because it may not be the same in all situations, some will do an optimization in all situations, but not in all. For this there is the EXPLAIN in most banks.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.