美文网首页
什么是多表关联查询,有几种多表关联的查询方式,分别是什么?

什么是多表关联查询,有几种多表关联的查询方式,分别是什么?

作者: 寧寧欧尼 | 来源:发表于2018-09-27 19:11 被阅读0次

    多表查询

    外键:只因用另一个表中的一列或者多列,被引用的列应该具有主键约束或唯一性约束。外键用于建立和加强两个表数据之间的连接。

    多表查询关联查询有哪些?

    • 内连接:inner join
    • 左外连接:left outer join
    • 右外连接:right outer join
    • 全外连接:full outer join
      但是最后的全外连接基本在实际中用不上,很多数据库管理系统也不支持全外连接

    select * from table1 left join select * from table2 on table1.id=table2.id 左连接
    select * from table1 right join select * from table2 on table1.id=table2.id 右连接
    select * from table1 cross join select * from table2 交叉连接
    select * from table1 union join select * from table2 on table1.id=table2.id
    select * from table1 where table1.id in (select id from table 2)

    相关文章

      网友评论

          本文标题:什么是多表关联查询,有几种多表关联的查询方式,分别是什么?

          本文链接:https://www.haomeiwen.com/subject/omkyoftx.html