舉個列子,
table1 有A,B,C三列
假設資料有
A B C
A001 B001 C001
A002 B002 C001
A003 B003 C001
table2 有 A,B,C,D,E
假設資料有
A B C D E
A001 B001 C001 ... ..
A002 B002 C001 ... ..
A004 B004 C001 ... ..
問題: 我想查出兩份表中C列=‘C001’的 A,B兩列的資料,去除重復的資料。
uj5u.com熱心網友回復:
查詢結果,以什么樣的形式展示呢?uj5u.com熱心網友回復:
select a,b from table1 where c='C001' unionselect a,b from table2 where c='C001'
是想問Union 和union all的區別吧?
uj5u.com熱心網友回復:
方法一:select A,B from table1 where C='C001'
union
select A,B from table2 where C='C001'
方法二:
select
distinct -- 去除重復項
*
from(
select A,B from table1 where C='C001'
union all
select A,B from table2 where C='C001')
uj5u.com熱心網友回復:
樓上正解,樓豬是要干什么?轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/85233.html
標籤:高級技術
上一篇:ORA-12592: TNS: 包錯誤,已快折磨死去,救命啊
下一篇:求助ORACLE查詢慢
