쿼리문 질문있습니다

쿼리문 질문있습니다

QA

쿼리문 질문있습니다

본문

orderinquirtview.php 입니다



<?php
$st_count1 = $st_count2 = 0;
$custom_cancel = false;

$sql = " select it_id, it_name, ct_send_cost, it_sc_type
            from {$g5['g5_shop_cart_table']}
            where od_id = '$od_id'
            group by it_id
            order by ct_id ";
$result = sql_query($sql);
?>
<div class="tbl_head03 tbl_wrap">
    <table>
    <thead>
    <tr>
        <th scope="col" rowspan="2">이미지</th>
        <th scope="col" colspan="7" id="th_itname">상품명</th>
    </tr>
    <tr class="th_line">
        <th scope="col" id="th_itopt">옵션명</th>
        <th scope="col" id="th_itqty">수량</th>
        <th scope="col" id="th_itprice">판매가</th>
        <th scope="col" id="th_itsum">소계</th>
        <th scope="col" id="th_itpt">적립포인트</th>
        <th scope="col" id="th_itsd">DOWNLOAD</th>
        <th scope="col" id="th_itst">상태</th>
    </tr>
    </thead>
    <tbody>
    <?php
    for($i=0; $row=sql_fetch_array($result); $i++) {
        $image = get_it_image($row['it_id'], 70, 70);

        $sql = " select ct_id, it_name, ct_option, ct_qty, ct_price, ct_point, ct_status, io_type, io_price
                    from {$g5['g5_shop_cart_table']}
                    where od_id = '$od_id'
                      and it_id = '{$row['it_id']}'
                    order by io_type asc, ct_id asc ";
        $res = sql_query($sql);
        $rowspan = sql_num_rows($res) + 1;

        // 합계금액 계산
        $sql = " select SUM(IF(io_type = 1, (io_price * ct_qty), ((ct_price + io_price) * ct_qty))) as price,
                        SUM(ct_qty) as qty
                    from {$g5['g5_shop_cart_table']}
                    where it_id = '{$row['it_id']}'
                      and od_id = '$od_id' ";
        $sum = sql_fetch($sql);

여기에서 

$g5{'g5_shop_item_table'}의 여분필드중 하나인 it_1_subj 를 가지고 오고싶은데

쿼리문을 어떻게 짜야될지 모르겟네요

이 질문에 댓글 쓰기 :

답변 2

칼럼 값이 다르기 때문에 이렇게 쓰면 될거 같습니다. 아니면 as로 별칭을 다 주어도 될거 같구요.


$sql = " select it_id, it_name, ct_send_cost, it_sc_type, it_1_subj
            from {$g5['g5_shop_cart_table']}, $g5{'g5_shop_item_table'}
            where od_id = '$od_id'
            group by it_id
            order by ct_id ";
답변을 작성하시기 전에 로그인 해주세요.
전체 62
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT