查询两张表中的共有数据
刚刚在提问栏目里面看见的一个问题:问题描述:
在ORACL数据库中表table1有字段codeid和cedename两个字段,表table2中也有codeid和codename字段,如何用一条SQL语句将这两张表的两个字段查询出来
解决办法:
查询 这两张表的数据
select t1.codeid ,t1.cedename fromtable1 t1 union all select t2.codeid ,t2.cedename fromtable1 t2
查询 这两张表的数据(去掉重复数据)
select t1.codeid ,t1.cedename fromtable1 t1 union select t2.codeid ,t2.cedename fromtable1 t2
帖地址:http://www.iteye.com/problems/90194
union:并集 所有的都查询重复的只显示一次union all :并集 所有的都查询 显示重复的intersect :交集 只显示重复的minus:差集
页:
[1]