SQL INNER JOIN syntax

后端 未结 7 2130
夕颜
夕颜 2020-12-01 05:16

the two bits of SQL below get the same result

SELECT c.name, o.product  
FROM customer c, order o  
WHERE c.id = o.cust_id  
AND o.value = 150  

SELECT c.na         


        
相关标签:
7条回答
  • 2020-12-01 06:16

    The JOIN... ON... syntax is a more recent addition to ANSI and ISO specs for SQL. The JOIN... ON... syntax is generally preferred because it 1) moves the join criteria out of the WHERE clause making the WHERE clause just for filtering and 2) makes it more obvious if you are creating a dreaded Cartesian product since each JOIN must be accompanied by at least one ON clause. If all the join criteria are just ANDed in the WHERE clause, it's not as obvious when one or more is missing.

    0 讨论(0)
提交回复
热议问题