left join 으로 주문상품을 불러오려고 하는데 도움 부탁드려요~
본문
장바구니 ct_event 에 값이 있는 주문상품을 마이페이지에서 불러오려고 하는데 잘 안되네요.ㅜㅜ
g5_shop_order와 g5_shop_cart 의 같은 od_id를 찾고 그리고 g5_shop_cart에서 ct_event에 값이
있는 주문상품을 g5_shop_order에서 불러오려고 합니다.
도움 부탁 드려요ㅜ~
orderinquiry.sub.php 에서 상단 부분입니다.
$sql = " select *
from {$g5['g5_shop_order_table']} a
left join {$g5['g5_shop_cart_table']} b on (a.od_id=b.od_id and b.ct_event > 0)
where mb_id = '{$member['mb_id']}'
order by od_id desc
$limit ";
답변 1
g5_shop_cart에서 ct_event라는 필드는 원래는 없는데 추가 하신건가요?
$sql = " select * from {$g5['g5_shop_order_table']} as a left join {$g5['g5_shop_cart_table']} as b on a.od_id = b.od_id where a.mb_id = '{$member['mb_id']}' and b.ct_event <> '' order by a.od_id desc $limit ";
이런식으로 되어야 할거같은데요..
ct_event가 기본값이 null 이라면 b.ct_event is not null 해주시면 됩니다.
!-->
답변을 작성하시기 전에 로그인 해주세요.