当前位置:首页 > 开发 > 数据库 > 正文

SQL的各种连接(cross join、inner join、full join)的用法理解

发表于: 2015-07-12   作者:zuo0209   来源:转载   浏览:
摘要: #交叉连接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.i
#交叉连接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;

SQL的各种连接(cross join、inner join、full join)的用法理解

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号