Mysql 1:n(1:多) 하나의 필드에 표현

1. main table : phone_spec – 1

2. sub table : phone_color – n(多)

3. group_concat 사용

select
group_concat(t2.colorname SEPARATOR ‘||’) as c_colorname,
group_concat(t2.DVIC_CLR_IMGE SEPARATOR ‘||’) c_DVIC_CLR_IMGE,
t1.* from phone_spec as t1 , phone_color as t2
where t1.sid = t2.psid
group by t2.psid

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다