自连接查询
要求查询学生表中和吴刚同一个来源地的学生的所有消息
select t1.*
from student1 t1,student1 t2
where t1.origin = t2.origin
and t2.name = "吴刚"
![](https://i-blog.csdnimg.cn/blog_migrate/fa9a1bc449c469c6f69fc433c884b3f0.png)
两表间不等值连接查询
select st.name , st.birthday , n.年代
from student1 st,nddzb n
where st.birthday between n.起始年份 and n.终止年份
![](https://i-blog.csdnimg.cn/blog_migrate/ec6d2cbdb982919539567f2f1ee6f45c.png)
mysql中没有full outer join 全外连接,用UNION 将左外连接和右外连接联合起来使用达到此目的
![](https://i-blog.csdnimg.cn/blog_migrate/6ad69067d055fb0dd84a44db3aa236c0.png)