链接查询的几种方式

1.外链接

   分为 左连接left outer join、右连接right outer join、全外连接

   左右外连接都会以一个表为基表,基表的所有行、列都会显示,外表条件不匹配则全显示null

   左:select * from tableA left join tableB on tableA.id = tableBid;

   右:select * from tableA right join TableB on TableA.id = tableB.id;

   全外:select * from tableA full join tableB on tableA.id = tableB.id;

   注:outer能省略  on 能替换成where

2.内连接

   例子:

  select * from tableA join tableB on tableA.id = tableB.id;

  select * from tableA , tableB where tableA.id = tableB.id;

3.交叉链接

  没有where条件的交叉链接产生的表为笛卡尔积。即 tableA*tableB的行数。

  例子:select * from tableA cross join tableB;

             select * from tableA , tableB;

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值