본문 바로가기

DataBase(SQL)/DAY 25 _ 23.09.21

집합 연산

1) 차집합

SELECT * FROM CUSTOMER c
minus
SELECT * FROM CUSTOMER c WHERE c.CUSTID in(1, 3, 5)

 

2) 교집합

SELECT * FROM CUSTOMER c
intersect
SELECT * FROM CUSTOMER c WHERE c.CUSTID in(1, 3, 5)

 

3) union : 두 개의 결과 집합을 하나로 합칠 수 있다.... 하지만 이해가 안된다면 패스

SELECT BOOKID a, BOOKNAME b FROM BOOK b
UNION
SELECT CUSTID a, NAME b FROM CUSTOMER c

'DataBase(SQL) > DAY 25 _ 23.09.21' 카테고리의 다른 글

Exists  (0) 2023.09.21
Sub Query2  (0) 2023.09.21
Where~in / inner join  (0) 2023.09.21
Sub Query  (0) 2023.09.21
Outer join  (0) 2023.09.21