안녕하세요?? Mysql 을 사용하는 중 Join 에 대해 궁금한 점이 있어서 글을 남깁니다.
song_temp -> 자료수 ( 1023323 개 )
album -> 자료수 ( 76237 개 )
album_detail -> 자료수 ( 76237 개 )
code -> 자료수 ( 171 개 )
현재 위의 4개의 테이블을 OUT JOIN 하려 합니다.
기준은 song_temp 테이블의 수량 만큼 나와야 하는 것이구요..
테이블 스키마를 적자면... 테이블 4개 구용...
참고로
code 테이블 code 필드와 album 테이블 genre_code 와 조인 되구요..
album 테이블 album_uid 와 song_temp 테이블 album_uid와 조인 되구요.
album 테이블 album_uid 와 album_detail 테이블 album_uid 와 조인이 됩니다.
조인되어서 결과 갯수가 song_temp 수량과 같게 나와야 하는데...
하단에 쿼리 한번 보시구요...
지도편달(?) 부탁드립니다....
TABLE album
album_uid
album_img_yn
title1
title2
title_search
title_key
genre_codee
album_type1
album_type2
nationality_code
volume
barcode
pid(FK)
oid
recommend
UPC
img_chk
TABLE album_detail
album_uid(FK)
regist_date
modify_date
release_date
album_profile
album_etc
runtime
management_code
TABLE song_temp
song_uid(FK)
album_uid(FK)
aod_uid(FK)
artlist_uid(FK)
cd_num
seq_num
titlesong
hitsong
regist_date
nationality_code
genre2_code
genre3_code
genre1_code
theme_code
title
title2
title_search
title_key
artist_name
artist_name_search
artist_name_key
ISRC
TABLE code
code
gubun
value
etc
쿼리는 아래와 같이 했습니다.
select count(*) from song_temp ,album ,album_detail ,code
LEFT OUTER JOIN album AB
ON song_temp.album_uid = AB.album_uid
LEFT OUTER JOIN album_detail AD
ON song_temp.album_uid = AD.album_uid
LEFT OUTER JOIN code CD
ON album_detail.album_etc = CD.etc
where song_temp.album_uid = album.album_uid
and album.album_uid = album_detail.album_uid
and code.code = album.genre_code;
|