0
我正在使用聯合運算符合並2個查詢的結果。現在我想在第二個查詢中使用第一個查詢的結果,這樣我就可以從第二個查詢中排除一些記錄。在較低查詢中使用union子句中的上部查詢的結果
E.g.
select <some_columns> from tableA Union select <same_columns> from tableA where <one_column_val> != <some_val_from_first_query>
下面是我的查詢
SELECT a.*, b.*, c.*
FROM tableA a,
tableB b,
tableC c
where b.field_1 = c.field_1
and a.field_2 = c.field_2
union
SELECT a.*, b.*, c.*
FROM tableA a,
tableB b,
tableC c
where b.field_1 = c.field_1
and a.field_3=c.field_3
and a.field_2 <> {a.field_2 from upper query}
請建議所需的改變。
在此先感謝