SQL的各种衔接(cross join、inner join、full join)的用法了解ITeye - 牛牛娱乐

SQL的各种衔接(cross join、inner join、full join)的用法了解ITeye

2019年04月04日08时19分03秒 | 作者: 天风 | 标签: 衔接,省掉,穿插 | 浏览: 882

#穿插衔接CROSS JOIN 又称为笛卡尔积
SELECT student.*,score.* FROM student, score
SELECT student.*,score.* FROM student CROSS JOIN score

#内衔接 INNER可省掉
SELECT stu.*,score.* FROM student stu,score WHERE
stu.id = score.stu_id

SELECT stu.*,score.* FROM student stu  INNER JOIN score ON
stu.id = score.stu_id

#左外衔接 左衔接  OUTER可省掉
SELECT stu.*,score.* FROM student stu  LEFT  OUTER JOIN score ON
stu.id = score.stu_id

#右外衔接 右衔接  OUTER可省掉
SELECT stu.*,score.* FROM student stu  RIGHT OUTER JOIN score ON
stu.id = score.stu_id

#全外衔接  MySQL不支持FULL JOIN
SELECT student.*,score.* FROM student FULL OUTER JOIN score ON student.id = score.stu_id;
版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表牛牛娱乐立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章