1.将stu表和sc表做连接:
select * from stu left join sc on stu.s_id=sc.s_id;
2.将stu表和sc表和co表做连接:
select * from stu left join sc on stu.s_id=sc.s_id left join co on sc.c_id=co.c_id;
3.将四表做连接:
select * from stu left join sc on stu.s_id=sc.s_id left join co on sc.c_id=co.c_id
left join te on co.t_id=te.t_id;
4.将四表做连接,删除不必要字段:
select stu.*,co.c_id,c_name,score,te.* from stu left join sc on stu.s_id=sc.s_id
left join co on sc.c_id=co.c_id
left join te on co.t_id=te.t_id;
5.将stu表和stu表做纵向链接:
select * from stu union select * from stu;
6.将stu表和stu表做纵向链接(不自动去重):
select * from stu union all select * from stu;
7.将stu表的s_id、s_name与co表的c_id、c_name做纵向链接:
select s_id,s_name from stu union select c_id,c_name from co;








暂无数据