2013-10-25 36 views
0

我有两个tabls比较其他表中缺少数据不存在

表1

name  | column 

animals | fish 
animals | cow 
buildings| house 
cars  | BMW 
cars  | Ford 

表2

name  | column 
     | 
animals | fish 
     | 
buildings| house 

cars  | Ford 

我想写一个查询显示丢失的2列(宝马和牛)如下:

name  | column 
animals | Cow 
Cars  | BMW 

我试图写这样的查询:

选择t1.column
从表1 T1
其中不存在(来自表2 T2选择1其中t1.column = t2.column)

但它给我空的结果,任何人都可以修复查询?

回答

1

试试这个:

Select name,column from table1 
minus 
select name,column from table2