Java工程师

JOIN 按照功能可分为如下三类:

INNER JOIN(内连接,或等值连接):获取两个表中字段匹配关系的记录;
LEFT JOIN(左连接):获取左表中的所有记录,即使在右表没有对应匹配的记录;
RIGHT JOIN(右连接):与LEFT JOIN 相反,用于获取右表中的所有记录,即使左表没有对应匹配的记录(很少使用)。
sql七种用法:

1.INNER JOIN(内连接)

SELECTFROM Table_A A INNER JOIN Table_B B ON A.Key = B.Key

2.LEFT JOIN(左连接)

SELECTFROM Table_A A LEFT JOIN Table_B B ON A.Key = B.Key

3.RIGHT JOIN(右连接

SELECTFROM Table_A A RIGHT JOIN Table_B B ON A.Key = B.Key

4.OUTER JOIN(外连接)

SELECTFROM Table_A A FULL OUTER JOIN Table_B B ON A.Key = B.Key

5.LEFT JOIN EXCLUDING INNER JOIN(左连接-内连接)

SELECTFROM Table_A A LEFT JOIN Table_B B ON A.Key = B.Key WHERE B.Key IS NULL

6.RIGHT JOIN EXCLUDING INNER JOIN(右连接-内连接)

SELECTFROM Table_A A RIGHT JOIN Table_B B ON A.Key = B.Key WHERE A.Key IS NULL

(剩余60%的优质内容,请移步Vx公众号 艾谷度Agoodu 阅读,谢谢!!)