自学内容网 自学内容网

sql join

(inner) join

selects records that have matching values in both tables
表中存在至少一个匹配时返回行,两张表中都有的数据才会显示。

left (outer) join

returns all records from the left table (table1), and the matching records from the right table (table2). The result is 0 records from the right side, if there is no match.
从左表(table1)返回所有的行,即使右表(table2)中没有匹配。如果右表中没有匹配,则该行中的右表字段显示为 NULL。

right (outer) join

returns all records from the right table (table2), and the matching records from the left table (table1). The result is 0 records from the left side, if there is no match.
从右表(table2)返回所有的行,即使左表(table1)中没有匹配。如果左表中没有匹配,则该行中的左表字段显示为 NULL。

full (outer) join

returns all records when there is a match in left (table1) or right (table2) table records.
只要左表(table1)和右表(table2)其中一个表中存在匹配,则返回行.。
FULL OUTER JOIN 关键字结合了 LEFT JOIN 和 RIGHT JOIN 的结果。
“全连接”,两张表中所有数据都显示。

self join

the table is joined with itself.

SELECT column_name(s)
FROM table1 T1, table1 T2
WHERE condition;

SQL 连接(JOIN) | 学SQL (learnsql.cn)icon-default.png?t=N7T8https://learnsql.cn/docs/sql_language/SQL_JOIN/SQL Joins (w3schools.com)icon-default.png?t=N7T8https://www.w3schools.com/SQL/sql_join.asp


原文地址:https://blog.csdn.net/wacpguo/article/details/140522307

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!