外连接分为"左外连接(左连接)","右外连接(右连接)"两种情况: left join / right join
常见格式是: SELECT A.IDA,A.VA,B.IDB,B.VB FROM TA A LEFT JOIN TB B
ON B.IDB=A.IDA
左连接:以左表为基础来连接,如果左表的某行内容无法在右表中找到相对的row,则将右表统统用null来表示.
右连接:与左连接相反.
内连接是最常用的链接,也叫等值链接,最常见的格式是:
SELECT a.*,b.* FROM TA as a ,TB as b
WHERE a.id=b.id
或者用inner join:
SELECT a.*,b.* FROM TA as a inner join TB as b
ON a.id = b.id
|