DB 6일차 3-1(union)
2022. 12. 14. 11:53ㆍ코딩배움일지/DataBase
다른 테이블 합칠때 테이블의 형태가 같아야 한다.
순서도 같아야 한다.
select
name
from
user_dtl
union /* union 중복 제거 해서 보여줌 unionall 중복제거 안하고 보여줌*/
select
name
from
score_mst;
select /*순서 일치*/
name,
email
from
user_dtl
union /* union 중복 제거 해서 보여줌 unionall 중복제거 안하고 보여줌*/
select
name,
null as email
from
score_mst;
select /*순서 일치*/
name,
email,
0 as score
from
user_dtl
union /* union 중복 제거 해서 보여줌 unionall 중복제거 안하고 보여줌*/
select
name,
null as email,
score
from
score_mst;
select /*순서 일치*/
name,
email,
0 as score
from
user_dtl
union /* union 중복 제거 해서 보여줌 unionall 중복제거 안하고 보여줌*/
select
name,
null as email,
score
from
score_mst
where
score > 80 ;
select /*순서 일치*/
name,
email,
0 as score
from
user_dtl
where
name = '김준일'
union /* union 중복 제거 해서 보여줌 unionall 중복제거 안하고 보여줌*/
select
name,
null as email,
score
from
score_mst
where
score > 80 ;
'코딩배움일지 > DataBase' 카테고리의 다른 글
DB 7일차(java, sql 연결 select) (0) | 2022.12.15 |
---|---|
DB 6일차 4(jdbc) (0) | 2022.12.14 |
DB 6일차 3(조건) (0) | 2022.12.14 |
DB 6일차 2() (0) | 2022.12.14 |
DB 6일차 1(서브쿼리) (0) | 2022.12.14 |