CREATE TABLE test1
(
no int
);
CREATE TABLE test2
(
no int
);
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엔터테이먼트';
Column의 갯수가 달라 에러 발생
SELECT name, job_title FROM celeb WHERE job_title LIKE '%가수%'
UNION
SELECT name, birthday, age FROM celeb WHERE birthday BETWEEN '1979-12-31' AND '1990-01-01';
SELECT * FROM celeb WHERE job_title LIKE '%가수%'
UNION
SELECT * FROM celeb WHERE job_title LIKE '%텔런트%';
SELECT * FROM celeb WHERE name LIKE '이%'
UNION ALL
SELECT * FROM celeb WHERE birthday BETWEEN '1970-01-01' AND '1979-12-31';