엔지니어가 되고 싶은 공돌이
10. Introduction to SQL (4) - Set Operation 본문
10. 1 Basic
1. union: 합집합(or)
2. intersect: 교집합(and)
3. except: 차집합(but not)
- Find courses that ran in Fall 2009 or in Spring 2010
(select course_id from section where sem = ‘Fall’ and year = 2009)
union
(select course_id from section where sem = ‘Spring’ and year = 2010)
- Find courses that ran in Fall 2009 and in Spring 2010
(select course_id from section where sem = ‘Fall’ and year = 2009)
intersect
(select course_id from section where sem = ‘Spring’ and year = 2010)
- Find courses that ran in Fall 2009 but not in Spring 2010
(select course_id from section where sem = ‘Fall’ and year = 2009)
except
(select course_id from section where sem = ‘Spring’ and year = 2010)
- 자동으로 중복을 제거한다
중복을 제거하고 싶지 않다면 union all, intersect all, except all을 사용한다.
10. 2 null
- 5 + null returns null
- 급여가 null인 모든 강사를 찾으시오.
: select name
from instructor
where salary is null
- is not null도 존재. null이 아닐때 만족.
- OR: (unknown or true) = true,
(unknown or false) = unknown
(unknown or unknown) = unknown
- AND: (true and unknown) = unknown,
(false and unknown) = false,
(unknown and unknown) = unknown
- NOT: (not unknown) = unknown
'Computer Science > Data Base' 카테고리의 다른 글
11. Introduction to SQL (5) - Aggregate Functions (0) | 2019.10.17 |
---|---|
09. Introduction to SQL (3) - 부가적인 기본연산 (0) | 2019.10.16 |
08. Introduction to SQL (2) - Basic Query Structure (0) | 2019.10.16 |
07. Introduction to SQL (1) - Domain type & create, drop (0) | 2019.10.16 |
06. Intro to Relational Model(2) - Query Language (0) | 2019.10.16 |