1:编号为003的员工信息优先显示:
select * from table_a where 员工编号='003'
union
select * from table_b where 员工标号!='003'
select A.jh from zscsg_jdbc A where A.jh='翻131-49'
union
select B.jh from zscsg_jd B where B.jh != '翻131-49'
2:求交集
intersect函数:Intersect(Set1 , Set2 [ , ALL ] )
select A.jh from zscsg_jdbc A
intersect
select B.jh from zscsg_jd B
3:查询表A有,但是表B没有的数据(A的id:1,2,3,4,5,6,7||B的ID:1,2,3,4,5)
select * from student A
left join student_1 B on A.ID=B.ID
where B.ID is null
select * from table_a where 员工编号='003'
union
select * from table_b where 员工标号!='003'
select A.jh from zscsg_jdbc A where A.jh='翻131-49'
union
select B.jh from zscsg_jd B where B.jh != '翻131-49'
2:求交集
intersect函数:Intersect(Set1 , Set2 [ , ALL ] )
select A.jh from zscsg_jdbc A
intersect
select B.jh from zscsg_jd B
3:查询表A有,但是表B没有的数据(A的id:1,2,3,4,5,6,7||B的ID:1,2,3,4,5)
select * from student A
left join student_1 B on A.ID=B.ID
where B.ID is null
本文介绍了几种常见的SQL查询技巧,包括如何优先显示特定员工信息、如何使用Intersect函数求两个集合的交集,以及如何找出一个表中有而另一个表中没有的数据。通过这些技巧的学习,可以提高SQL查询效率。
6194

被折叠的 条评论
为什么被折叠?



