sql语句之连表操作

 

内连接

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

 

内连接:将值为null的行全部隐藏

多表查询远不止此,还包括子查询等

posted @ 2018-03-14 11:14  Claire_xu  阅读(429)  评论(0编辑  收藏  举报