조인 오류 질문

조인 오류 질문

QA

조인 오류 질문

본문

orderinquiryview.php 입니다

 



$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);

// 배송비
switch ($row['ct_send_cost']) {
    case 1:
        $ct_send_cost = '착불';
        break;
    case 2:
        $ct_send_cost = '무료';
        break;
    default:
        $ct_send_cost = '선불';
        break;
}

// 조건부무료
if ($row['it_sc_type'] == 2) {
    $sendcost = get_item_sendcost($row['it_id'], $sum['price'], $sum['qty'], $od_id);

    if ($sendcost == 0)
        $ct_send_cost = '무료';
}

for ($k = 0; $opt = sql_fetch_array($res); $k++) {
    if ($opt['io_type'])
        $opt_price = $opt['io_price'];
    else
        $opt_price = $opt['ct_price'] + $opt['io_price'];

    $sell_price = $opt_price * $opt['ct_qty'];
    $point = $opt['ct_point'] * $opt['ct_qty'];

    if ($k == 0) {
        ?>
    <?php } ?>

    <tr>
        <td headers="th_itopt" class="td_prd">
            <div class="sod_img"><?php echo $image; ?></div>
            <div class="sod_name">
                <a href="<?php echo shop_item_url($row['it_id']); ?>"><?php echo $row['it_name']; ?></a><br>
                <div class="sod_opt"><?php echo get_text($opt['ct_option']); ?></div>
            </div>
        </td>

        <td headers="th_itqty" class="td_mngsmall"><?php

            $sql1 = " select a.it_id, a.it_name, a.ct_send_cost, a.it_sc_type, b.it_1_subj
             from {$g5['g5_shop_cart_table']} a,{$g5['g5_shop_item_table']} b
            where a.od_id = '$od_id'
            group by a.it_id
            order by a.ct_id ";
            $result1 = sql_query($sql1, true);

            for ($l = 0; $row1 = sql_fetch_array($result1); $l++) {
                $filename = get_text($row1['it_1_subj']);
                var_dump($row1);
                if (preg_match('/\.(jpe?g|gif|png|psd|skp|)$/i', $filename, $matches)) {
                    echo $matches[1] . '파일';
                }
            }
            ?>

        </td>
        <td headers="th_itprice"
            class="td_numbig text_right"><?php echo number_format($opt_price); ?></td>
        <td headers="th_itpt"
            class="td_numbig text_right"><?php echo number_format($point); ?></td>
        <?php

        if ($opt['ct_status'] == "완료") {

            $tag = "<a href='download.php?id=$od_id&iid={$row['it_id']}'> DOWN</a>";
        } else {
            $tag = "";
        }
        ?>
        <td headers="th_itsd" class="td_dvr"><?= $tag ?></td>
        <!--                                <td headers="th_itsum"-->
        <!--                                    class="td_numbig text_right">-->
        <?php //echo number_format($sell_price); ?><!--</td>-->
        <td headers="th_itst" class="td_mngsmall"><?php echo $opt['ct_status']; ?></td>
    </tr>

 

item 테이블의 여분 필드인 it_1_subj 를 가져오려고 하는데 

다른건 잘 가져오는데

이 여분필드만 못가져 옵니다 ㅠ

어떻게 수정을 해야될까요?

 

3718050134_1641175393.2519.png 버스정류장 skp가 들어가있어야합니다

 

이 질문에 댓글 쓰기 :

답변 1

item 테이블에 it_1_subj 라는 칼럼이 있고 안에 데이터가 있다고 가정하고 말씀드릴께요

 



$sql1 = " select a.it_id, a.it_name, a.ct_send_cost, a.it_sc_type, b.it_1_subj
             from {$g5['g5_shop_cart_table']} a,{$g5['g5_shop_item_table']} b
            where a.od_id = '$od_id'
            group by a.it_id
            order by a.ct_id ";

 
=>
 
 

$sql1 = " select a.it_id, a.it_name, a.ct_send_cost, a.it_sc_type, b.it_1_subj
             from {$g5['g5_shop_cart_table']} as a inner join {$g5['g5_shop_item_table']} as b
              on a.it_id = b.it_id
            where a.od_id = '$od_id'
            group by a.it_id
            order by a.ct_id ";

쿼리를 위처럼 고쳐보시기 바랍니다

답변을 작성하시기 전에 로그인 해주세요.
전체 720
QA 내용 검색
filter #sql ×

회원로그인

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