USE zerobase;
SELECT * FROM celeb;
CREATE TABLE test1 ( no int );
CREATE TABLE test2
(
no int
);
![](https://velog.velcdn.com/images/hjh918/post/78898c20-af81-4bd3-a10f-4f7b4684d810/image.png)
![](https://velog.velcdn.com/images/hjh918/post/5c2d40ac-6fc5-458d-b503-28b257d76cb3/image.png)
## 테스트 데이터 추가
>
```sql
INSERT INTO test1 VALUES (1);
INSERT INTO test1 VALUES (2);
INSERT INTO test1 VALUES (3);
INSERT INTO test2 VALUES (5); INSERT INTO test2 VALUES (6); INSERT INTO test2 VALUES (3);
SELECT * FROM test1;
SELECT * FROM test2;
SELECT column1, column2, ... FROM tableA UNION | UNION ALL SELECT column1, column2, ... FROM tableB;
SELECT * FROM test1 UNION ALL SELECT * FROM test2;
SELECT * FROM test1 UNION SELECT * FROM test2;
SELECT name, sex, agency FROM celeb WHERE sex = 'F' UNION ALL SELECT name, sex, agency FROM celeb WHERE agency = 'YG엔터테인먼트';
SELECT name, sex, agency FROM celeb WHERE sex = 'F' UNION SELECT name, sex, agency FROM celeb WHERE agency = 'YG엔터테인먼트';
SELECT name, job_title FROM celeb WHERE job_title LIKE '%가수%';
SELECT name, birthday, age FROM celeb WHERE birthday BETWEEN '1980-01-01' AND '1989-12-31';
SELECT name, job_title FROM celeb WHERE job_title LIKE '%가수%' UNION SELECT name, birthday, age FROM celeb WHERE birthday BETWEEN '1980-01-01' AND '1989-12-31';
위 글은 제로베이스 데이터 취업 스쿨의 강의자료를 참고하여 작성되었습니다.