首页 > 数据库技术 > 详细

sql语句之多表查询

时间:2018-03-14 12:10:54      阅读:210      评论:0      收藏:0      [点我收藏+]

 

内连接

select * from employee inner join department on employee.dep_id = department.id

 

左连接  在内连接的基础上保留左表记录

select * from employee left join department on employee.dep_id = department.id

 

右连接  在内连接的基础上保留右表记录

select * from employee right join department on employee.dep_id = department.id

 

全外连接

mysql不支持full join。若要实现该效果,可用下面语句实现:

select * from employee left join department on employee.dep_id = department.id union

select * from employee right join department on employee.dep_id = department.id

sql语句之多表查询

原文:https://www.cnblogs.com/stin/p/8566228.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!