SELECT bun AS 번호, pummok AS 상품명 FROM pum1 UNION SELECT num, sangpum FROM pum2;
연습문제
SELECT jikwon_jik FROM jikwon WHERE jikwon_name = '박치기'; -- 문장1
SELECT FROM jikwon WHERE jikwon_jik = '사원'; -- 문장2
-- 문1 + 문2
SELECT FROM jikwon WHERE jikwon_jik = (SELECT jikwon_jik FROM jikwon WHERE jikwon_name = '박치기');
SELECT FROM jikwon WHERE jikwon_ibsail = ( SELECT MIN(jikwon_ibsail) FROM jikwon WHERE jikwon_jik = '대리'); -- 오류날 수 있음
SELECT FROM jikwon WHERE jikwon_jik = '대리' AND
jikwon_ibsail = ( SELECT MIN(jikwon_ibsail) FROM jikwon WHERE jikwon_jik = '대리');
SELECT * FROM jikwon WHERE buser_num = (SELECT buser_no FROM buser WHERE buser_loc = '인천');
-- 서브쿼리 한개씩 반환하기 때문에 "=" 씀
SELECT * FROM jikwon WHERE buser_num IN (SELECT buser_no FROM buser WHERE not buser_loc = '인천');
-- 서브쿼리에서 여러개씩 반환하기 때문에 "IN" 씀
SELECT * FROM gogek WHERE gogek_damsano = (SELECT gogek_damsano FROM gogek WHERE gogek_name = '김혜순');
SELECT * FROM gogek WHERE substr(gogek_jumin,1,2) = (SELECT substr(gogek_jumin,1,2) FROM gogek WHERE gogek_name = '이영희');