테스트 사이트 - 개발 중인 베타 버전입니다

쿼리문 질문있습니다 채택완료

니냐노 4년 전 조회 1,440

orderinquirtview.php 입니다

</p>

<pre>
<?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);</pre>

<p>

여기에서 

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

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

댓글을 작성하려면 로그인이 필요합니다.

답변 2개

채택된 답변
+20 포인트

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

</p>

<p>$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 ";</p>

<p>

로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

select가 세 곳인데

여기서"가 어디인지 모르겠으나

g5_shop_cart 하고 g5_shop_item하고 join해서 가져 오시면 될 겁니다.
로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인