MySQL之left jion 、 right jion 和inner jion 的区别和使用方法

left jion   左联结

right jion 右联结

inner jion 等值联结

 

 1 create table teacher(
 2    tid  int(5) primary key auto_increment,
 3    tname varchar(100) not null,
 4    age  int,
 5    phone char(11)
 6 )engine=INNODB
 7 
 8 /*插入信息*/
 9 insert into teacher(tname,age,phone) values('张三',54,'18919900000');
10 
11 /* 哪些老师带课了*/
12  select distinct(t.tname) ,t.age
13  from teacher t inner join course c
14  on t.tid=c.tid  ;
15 
16 /*哪些老师没有代课*/
17     select t.tname,t.age,c.cname
18     from teacher t left join course c
19     on t.tid=c.tid
20     where c.cname is null  ;       

以上完整性不足,往后补上....

这里写的不错,转载:https://www.cnblogs.com/pcjim/articles/799302.html

转载于:https://www.cnblogs.com/liangwh520/p/MySQL.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值