Oracle 将其他表中缺少的数据与不存在的数据进行比较
我有两张桌子 表1Oracle 将其他表中缺少的数据与不存在的数据进行比较,oracle,Oracle,我有两张桌子 表1 name | column animals | fish animals | cow buildings| house cars | BMW cars | Ford 表2 name | column | animals | fish | buildings| house cars | Ford 我尝试编写一个查询时,会显示缺少的2列bmw和cow,如下所示: name | col
name | column
animals | fish
animals | cow
buildings| house
cars | BMW
cars | Ford
表2
name | column
|
animals | fish
|
buildings| house
cars | Ford
我尝试编写一个查询时,会显示缺少的2列bmw和cow,如下所示:
name | column
animals | Cow
Cars | BMW
我试着写下这样的疑问:
选择t1.1列
来自表1 t1
如果不存在,则从表2中选择1,其中t1.column=t2.column
但是它给了我一个空结果,有人能修复这个查询吗?试试这个:
Select name,column from table1
minus
select name,column from table2
SQLFiddle:
SELECT * FROM table_1 t1 WHERE
NOT EXISTS (SELECT 1 FROM table_2 t2 WHERE t1.column = t2.column);