SQL left join vs multiple tables on FROM line?

前端 未结 11 2384
予麋鹿
予麋鹿 2020-11-22 05:08

Most SQL dialects accept both the following queries:

SELECT a.foo, b.foo
FROM a, b
WHERE a.x = b.x

SELECT a.foo, b.foo
FROM a
LEFT JOIN b ON a.x = b.x
         


        
11条回答
  •  遇见更好的自我
    2020-11-22 05:46

    The JOIN syntax keeps conditions near the table they apply to. This is especially useful when you join a large amount of tables.

    By the way, you can do an outer join with the first syntax too:

    WHERE a.x = b.x(+)
    

    Or

    WHERE a.x *= b.x
    

    Or

    WHERE a.x = b.x or a.x not in (select x from b)
    

提交回复
热议问题