inner join 과 left join 함께 쓰기
select
table_order_detail.*
,table_order_detail.use_date as detail_use_date
,table_order_detail.cancel_date as detail_cancel_date
,table_order_detail.status as order_detail_status
,table_order_detail.sale_price as sale_price
,table_order.*
,table_member.mem_code
,table_member.mem_name
,table_channel.channel_code
,table_channel.channel_name
-- ,table_product_detail.deal_code
-- ,table_product_detail.option_name
-- ,table_product_detail.pos_id
-- ,table_product_detail.product_detail_code
,table_provider.prov_code
,table_provider.prov_name
,table_pos.pos_id
,table_pos.mem_code
,table_pos.pos_name
from
table_order_detail
inner join table_order on table_order_detail.order_num = table_order.order_num
inner join table_member on table_order.mem_code = table_member.mem_code
inner join table_channel on table_order.channel_code = table_channel.channel_code
inner join table_product on table_order.product_code = table_product.product_code
-- inner join table_product_detail on table_order_detail.option_name = table_product_detail.option_name
inner join table_product_detail on table_order_detail.product_detail_code = table_product_detail.product_detail_code
inner join table_provider on table_product.prov_code = table_provider.prov_code
left join table_pos on table_order_detail.pos_id = table_pos.pos_id
where 1 = 1 order by table_order_detail.order_num limit 100;
'DB > MySQL - MariaDB' 카테고리의 다른 글
Mysql 쿼리 튜닝 실행 계획 (0) | 2017.03.30 |
---|---|
Mysql 데이터 타입 변경 및 추가 명령어. (0) | 2017.03.25 |
MySQL에서 DATETIME 형식 데이터 고속 검색 방법 (3) | 2017.03.08 |
Mysql 에서 실행계획을 분석하는 방법 (0) | 2017.03.08 |
쿼리문 정규식 _ 내 해당하는 값 찾기 (0) | 2017.02.20 |