역순으로 처리됩니다. 이 작업을 수행합니다 : http://www.sqlfiddle.com/#!2/09239/3
SELECT Brand
FROM
(
-- Oracle can't make a row without a table, need to use DUAL dummy table
select 'FORD' as Brand from dual union
select 'HYUNDAI' from dual union
select 'TOYOTA' fom dual union
select 'BMW' from dual
) x
where Brand not in (select BrandName from account)
샘플 계정 데이터 :
create table account(AccountId int, BrandName varchar(10));
insert into account(AccountId, BrandName) values
(1,'FORD'),
(2,'TOYOTA'),
(3,'BMW');
출력 :
select *
from Brand
where BrandName not in (select BrandName from account)
:
| BRAND |
-----------
| HYUNDAI |
아직 더 나은
이 테이블에 브랜드를 구체화
출력 :
| BRANDNAME |
-------------
| HYUNDAI |
샘플 데이터와 실제 시험 : http://www.sqlfiddle.com/#!2/09239/1
CREATE TABLE Brand
(`BrandName` varchar(7));
INSERT INTO Brand
(`BrandName`)
VALUES
('FORD'),
('HYUNDAI'),
('TOYOTA'),
('BMW');
create table account(AccountId int, BrandName varchar(10));
insert into account(AccountId, BrandName) values
(1,'FORD'),
(2,'TOYOTA'),
(3,'BMW');
사용하고있는 DBMS 열에 표시해야합니까? –