Anda dapat menggunakan union
untuk membuat tabel kota dan kemudian minus
operator.
select 'Dallas' as city from dual union all
select 'Berlin' as city from dual union all
select 'Cracow' as city from dual union all
select 'Praha' as city from dual
minus
select city from address
Alih-alih serikat pekerja, Anda dapat menggunakan tipe standar odcivarchar2list
, yang memperpendek sintaks:
select column_value as city
from table(sys.odcivarchar2list('Dallas', 'Berlin', 'Cracow', 'Praha'))
minus
select city from address
... dan bukannya minus
Anda dapat menggunakan bergabung atau not in
atau not exists
.
Data uji dan keluaran dari kedua kueri:
create table address (id number, city varchar2(10));
insert into address values (1, 'Rome');
insert into address values (2, 'Dallas');
insert into address values (3, 'Cracow');
insert into address values (4, 'Moscow');
insert into address values (5, 'Liverpool');
insert into address values (6, 'Cracow');
insert into address values (7, 'Seoul');
CITY
------------
Berlin
Praha