赞
踩
外连接又分为:
左连接(left join);
右连接(right join);
全连接(union)
对以下三张表展开连接,分别为stu、cou、tea
stu中,字段为t_id ; t_name ; t_cid
cou 中,字段为 t_cid ; c_name ; t_id
tea中,字段为 t_id ; t_name
例1:对三表进行等值连接
语句:select * from stu,cou,tea where stu.t_cid=cou.t_cid and cou.t_id=tea.t_id;
结果:
例2:以cou为主表,对三表进行连接
语句:
select * from cou left join stu on cou.t_cid=stu.t_cid left join tea on cou.t_id=tea.t_id;
结果:
例3:对stu和cou两表进行全连接
语句:
select * from cou left join stu on cou.t_cid=stu.t_cid
union
select * from cou right join stu on cou.t_cid=stu.t_cid;
结果:
以上对表连接进行了简要的介绍和操作的说明,希望对大家有帮助~
See you!
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。