- 所属分类:网站建设知识
- 作者: 独占网络
- 更新时间: 2015-3-17 10:14:37
- 返回列表
联表查询使用union运算符可以将两个或两个以上select语句的查询结果合并成一个结果集合显示,也就是执行联合查询。
查询类别为1的员工,还有年龄大于20岁的员工
select * from users where typeid =1 union select * from users where age>20
union all 是另一种合并表的方法,它与union是很类似的,的区别是它不跟union子句一样删除重复的行也不对进行自动排序。
查询类别为1的员工,还有年龄大于20岁的员工
select * from users where typeid =1 union all select * from users where age>20
还有和中方法是加入查询的left join(联表查询)
select users.age,pc.info from users left join pc on users.typeid = pc.id
如有不懂找,深圳网站建设:独占网络