0

私は2つのテーブルを持っています

表1

name     | column

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

表 2

name     | column
         |
animals  | fish
         |
buildings| house

cars     | Ford

クエリを作成しようとすると、次のように欠落している 2 つの列 (bmw と牛) が表示されます。

name     | column
animals  | Cow
Cars     | BMW

私はそのようなクエリを書き込もうとしました:

select t1.column
from table 1 t1
where not exist (select 1 from table2 t2 where t1.column = t2.column)

しかし、空の結果が得られます。誰かがクエリを修正できますか?

4

2 に答える 2

1

これを試して:

Select name,column from table1
minus
select name,column from table2
于 2013-10-25T12:43:26.707 に答える
1
SELECT * FROM table_1 t1 WHERE 
    NOT EXISTS (SELECT 1 FROM table_2 t2 WHERE t1.column = t2.column);

SQLFiddle: http://sqlfiddle.com/#!2/399b2d/7

于 2013-10-25T12:44:24.080 に答える