/ W3SCHOOLS

W3schools - SQL_EXISTS / ANY / ALL

이 페이지는 다음에 대한 공부 기록입니다
Lecture에서 배웠던 내용을 복습하며 작성했습니다

찾으시는 정보가 있으시다면
주제별reference를 이용하시거나
우측 상단에 있는 검색기능을 이용해주세요

EXISTS

Is used to test for the existence of any record in a subquery

Returns TRUE if the subquery returns one or more records

SELECT column_name(s)
FROM table_name
WHERE EXISTS
(SELECT column_name FROM table_name WHERE condition);

ANY / ALL

Allow to perform a comparison between a single column value and a range of other values

ANY

Means that the condition will be true if the operation is true for any of the values in the range

Returns TRUE if ANY of the subquery values meet the condition

SELECT column_name(s)
FROM table_name
WHERE column_name operator ANY
(SELECT column_name
FROM table_name
WHERE condition);

ALL

Means that the condition will be true only if the operation is true for all values in the range

Is used with SELECT, WHERE and HAVING statements

Returns TRUE if ALL of the subquery values meet the condition

SELECT ALL column_name(s)
FROM table_name
WHERE condition;
-- with WHERE or HAVING
SELECT column_name(s)
FROM table_name
WHERE column_name operator ALL
(SELECT column_name
FROM table_name
WHERE condition);