일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | 7 |
8 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | 17 | 18 | 19 | 20 | 21 |
22 | 23 | 24 | 25 | 26 | 27 | 28 |
29 | 30 | 31 |
Tags
- Elasticsearch
- Python
- token filter test
- aggs
- Kafka
- 900gle
- 차트
- zip 파일 암호화
- TensorFlow
- MySQL
- ELASTIC
- matplotlib
- License
- query
- analyzer test
- license delete
- Test
- high level client
- docker
- Mac
- springboot
- 파이썬
- flask
- zip 암호화
- plugin
- API
- licence delete curl
- aggregation
- sort
- Java
Archives
- Today
- Total
개발잡부
[mysql] left join 안에서 group_concat 본문
반응형
이런 구조를 원했는데 이 구조가 left join 으로 전체쿼리속에 들어가야 하는 상황
left join 조건절에서 item_no 와 scate_cd 조건으로 걸어줌
left join (
select
uda.item_no ,
uda.scate_cd ,
group_concat(uda.gattr_no order by uda.ica_priority asc, uda.attr_no desc separator '|') as gattr_no ,
group_concat(uda.attr_no order by uda.ica_priority asc separator '|') as attr_no ,
group_concat(uda.attr_nm order by uda.ica_priority asc, uda.attr_no desc separator '|') as attr_nm ,
group_concat(uda.priority order by uda.ica_priority asc, uda.attr_no desc separator '|') as priority ,
group_concat(uda.mc_cd order by uda.ica_priority asc, uda.attr_no desc separator '|') as mc_cd ,
group_concat(uda.mc_nm order by uda.ica_priority asc, uda.attr_no desc separator '|') as mc_nm
from
(
select
iia.item_no ,
ima.gattr_no ,
ica.priority as ica_priority ,
ica.scate_cd ,
group_concat(ima.attr_no order by ima.priority asc separator ',') as attr_no ,
group_concat(ima.attr_nm order by ima.priority asc, ima.attr_no desc separator ',') as attr_nm ,
group_concat(ima.priority order by ima.priority asc, ima.attr_no desc separator ',') as priority ,
group_concat(distinct imc.mc_cd order by ima.priority asc, ima.attr_no desc separator ',') as mc_cd ,
group_concat(distinct imc.mc_nm order by ima.priority asc, ima.attr_no desc separator ',') as mc_nm
from
itm_mng_attr ima
inner join itm_mng_attr_group imag on
ima.gattr_no = imag.gattr_no
and imag.use_yn = 'Y'
and imag.gattr_type = 'ATTR'
inner join itm_item_attr iia on
ima.attr_no = iia.attr_no
and iia.use_yn = 'Y'
inner join itm_category_attr ica on
ica.attr_no = ima.gattr_no
and ica.use_yn = 'Y'
left join (
select
imc.ref_1,
imc.mc_cd,
imc.mc_nm
from
itm_mng_code imc
where
gmc_cd = 'wine_uda_id' ) imc on
imc.ref_1 = ima.gattr_no
where
ima.use_yn = 'Y'
and iia.item_no in ('158036890')
group by
ima.gattr_no,
iia.item_no,
ica.scate_cd ) as uda
group by
uda.item_no, uda.scate_cd ) uda_ATTR on
ii.item_no = uda_ATTR.item_no
and uda_ATTR.scate_cd = ic.scate_cd
반응형
'Database' 카테고리의 다른 글
[MySql] MySQLWorkbench EER diagram 그리기 (0) | 2023.09.04 |
---|---|
[MySQL] 테이블 구조와 데이터 복사 (0) | 2023.04.22 |
[mysql] PRIMARY KEY, UNIQUE KEY (0) | 2022.04.23 |
[Mysql] View (0) | 2022.04.01 |
[Mysql] Procedure (0) | 2022.04.01 |
Comments