SQL EXISTS Operator
The SQL EXISTS Operator
하위 쿼리를 만족하는 레코드가 있는지 테스트
if랑 비슷한 역할
만약 하위 쿼리가 1개 이상의 레코드를 반환하는 경우
EXISTS 연산자는 TRUE를 반환한다 .
EXISTS Syntax
SELECT column_name(s)
FROM table_name
WHERE EXISTS
(SELECT column_name FROM table_name WHERE condition);
SQL EXISTS Examples
SELECT SupplierName
FROM Suppliers
WHERE EXISTS (SELECT ProductName FROM Products WHERE Products.SupplierID = Suppliers.supplierID AND Price < 20);
SELECT SupplierName
FROM suppliers
WHERE EXISTS (SELECT ProductName FROM Products WHERE Products.SupplierID = Suppliers.supplierID AND Price = 22);
'Computer Science > Database' 카테고리의 다른 글
W3Schools SQL | #31 SQL INSERT INTO SELECT 구문 (0) | 2022.10.29 |
---|---|
W3Schools SQL | #29 SQL ANY ALL 연산자 (0) | 2022.10.28 |
W3Schools SQL | #27 SQL HAVING (0) | 2022.10.28 |
W3Schools SQL | #26 SQL GROUP BY STATEMENT (0) | 2022.10.28 |
W3Schools SQL | #25 SQL UNION 연산자 (0) | 2022.10.28 |