250x250
Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
Tags
- choice()
- discard()
- items()
- CSS
- count()
- HTML
- shuffle()
- JS
- 오버라이딩
- mro()
- 파이썬
- locals()
- View
- fileinput
- zipfile
- __annotations__
- randrange()
- node.js
- __len__
- MySqlDB
- glob
- fnmatch
- Database
- MySQL
- __sub__
- decode()
- __getitem__
- remove()
- shutil
- inplace()
Archives
- Today
- Total
흰둥이는 코드를 짤 때 짖어 (왈!왈!왈!왈!왈!왈!왈!왈!왈!왈!왈!)
(MySQL) 기초 문법(유니온) 본문
728x90
반응형
product, product_new 테이블
select * from product;
select * from product_new;


유니온(union)
- 합집합을 나타내는 연산자로, 중복된 값을 제거함
- 서로 같은 종류의 테이블(컬럼이 같아야 함)에서만 적용이 가능
# select 컬럼명1, 컬럼명2.. 테이블1 union select 컬럼명1, 컬럼명2.. from 테이블2
select code, name, price from product
union
select code, name, price from product_new;

중복이 되는 100001번 하나가 제외되어 출력된다.
select code, name, price, regdate from product
union
select code, name, price, regdate from product_new;

regdate의 값은 다르기 때문에 중복으로 인식하지 않아 100001번이 제외 되지 않고 출력된다.
union all
- 합집합을 나타내는 연산자로, 중복된 값을 제거하지 않음
select code, name, price from product
union all
select code, name, price from product_new;

100001번이 아예 중복되는 데이터지만 전부 출력한다.
728x90
반응형
'MySQL' 카테고리의 다른 글
(MySQL) 기초 문법(문자열 함수) (0) | 2023.03.20 |
---|---|
(MySQL) 기초 문법(서브 쿼리) (0) | 2023.03.20 |
(MySQL) 기초 문법(auto_increment) (0) | 2023.03.20 |
(MySQL) 정규화 (0) | 2023.03.20 |
(MySQL) 기초 문법(외래키, 조인) (1) | 2023.03.20 |