标签:select 右连接 bsp 关系 外连接 ima info join alt
1.内连接(只取两张表的共同部分)
# 将表employee 和 department 的相同部分根据employee表中的dep_id字段和department表中的id字段连接起来。 select * from employee inner join department on employee.dep_id = department.id;
2.左连接(在内连接的基础上保留左边表的记录)
select * from employee left join department on employee.dep_id = department.id;
3.右连接(在内连接的基础上保留右边表的记录)
select * from employee right join department on employee.dep_id = department.id;
4.全外连接(保留左右两表没有对应关系的记录)
# 将左连接和右连接查出来的记录和在一起,再去重~ 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;
标签:select 右连接 bsp 关系 外连接 ima info join alt
原文地址:https://www.cnblogs.com/wangdianchao/p/12271081.html