| > Although it’s possible to join using a WHERE clause (an implicit join), prefer an explicit JOIN instead, as the ON keyword can take advantage of the database’s index. This implies that WHERE style join can't use indices. I can understand why some would prefer either syntax for readability/style reasons. But the idea that one uses indices and the other not, seems highly dubious. Looking at the postgres manual [1], the WHERE syntax is clearly presented as the main way of inner joining tables. The JOIN syntax is described as an "alternative syntax": > This [INNER JOIN] syntax is not as commonly used as the one above, but we show it here to help you understand the following topics. Maybe some database somewhere cannot optimise queries properly unless JOIN is used? Or is this just FUD? [1] https://www.postgresql.org/docs/13/tutorial-join.html |
This is going to need some sources. Is it true today? And why did they put parentheses in the ON condition?
Worth nothing that there were variants of the WHERE syntax to support left joins using vendor-specific operators such as A += B, A = B (+) -- those are clearly deprecated today. [1] [2]
I have a really hard time finding any source on the internet that recommends using the WHERE style joins. So by extension, I wouldn't expect to be used much anymore except for legacy projects. MS SQL Server docs docs mention ON syntax being "preferred" [3], and MySQL says "Generally, the ON clause serves for conditions that specify how to join tables, and the WHERE clause restricts which rows to include in the result set." [4]
The PostgreSQL docs seem misleading and outdated to me.
[1] https://docs.microsoft.com/en-us/archive/blogs/wardpond/depr...
[2] https://docs.oracle.com/cd/B19306_01/server.102/b14200/queri...
[3] https://docs.microsoft.com/en-us/sql/relational-databases/pe...
[4] https://dev.mysql.com/doc/refman/5.7/en/join.html