sql 질문 채택완료
adm/shop_admin/ itemlist.php 에
</p>
<pre>
for ($i=0; $row=sql_fetch_array($result); $i++)
{
$href = shop_item_url($row['it_id']);
$bg = 'bg'.($i%2);
$it_point = $row['it_point'];
if($row['it_point_type'])
$it_point .= '%';
?>
<tr class="<?php echo $bg; ?>">
<td rowspan="3" class="td_chk">
<label for="chk_<?php echo $i; ?>" class="sound_only"><?php echo get_text($row['it_name']); ?></label>
<input type="checkbox" name="chk[]" value="<?php echo $i ?>" id="chk_<?php echo $i; ?>">
</td>
<td rowspan="3" class="td_radio">
<?php $sql2 = "select b.mb_data from {$g5['g5_shop_item_table']} as a right join {$g5['member_table']} as b
on a.it_maker = b.it_maker
where a.it_id={$it_id}";
$result1 = sql_query($sql2, true);
for($i=0; $row1=sql_fetch_array(result1); $i++){
var_dump($row1);
}
?>
</pre>
<p>
right조인으로
item table과 member테이블을 라이트 조인으로 해서
멤버 테이블의 mb_data만 뽑아오려고 하는데
SQL문이 틀려서 오류나는 데 어떻게 조인을 해야될까요?
답변 4개
</p>
<p><td rowspan="3" class="td_radio"></p>
<p><?php $sql2 = "select b.mb_data from {$g5['g5_shop_item_table']} as a right join {$g5['member_table']} as b on a.it_maker = b.it_maker where a.it_id={$row['it_id']}";</p>
<p>$result1 = sql_query($sql2, true);</p>
<p>for($i=0; $row1=sql_fetch_array($result1); $i++){</p>
<p> var_dump($row1);</p>
<p>}</p>
<p>?></p>
<p></td></p>
<p>
</p>
<p>결과 :</p>
<p>select b.mb_data from g5_shop_item as a right join g5_member as b on a.it_maker = b.it_maker where a.it_id=1642144074</p>
<p>1054 : Unknown column 'b.mb_data' in 'field list'</p>
<p>error file : /adm/shop_admin/itemlist.php</p>
<p>
g5_member table 에는 mb_data 라는 필드가 없어서 나오는 오류입니다.
정확하게 g5_member table 에서 어떤 값을 얻고 싶은건가요?
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
$g5['g5_shop_item_table']에서 select해서 loop를 도는데 왜
다시 조인을 사용하는지 모르겠네요.
그냥 {$g5['member_table']} 에서 가져 오면 될 텐데요..
답변에 대한 댓글 2개
그렇게만해도 충분하지 않을까요?
필요한 컬럼이 더 있으면 처음 loop(select from item)에서 가져 오면 되구요.
댓글을 작성하려면 로그인이 필요합니다.
<?php
$sql2 = " select b.mb_data, a.* from {$g5['g5_shop_item_table']} as a right join {$g5['member_table']} as b on a.it_maker = b.it_maker where a.it_id= '{$it_id}' ";
?>
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
코드에 에러가 있습니다.
</p>
<pre>
<code>for($i=0; $row1=sql_fetch_array(result1); $i++){</code></pre>
<p><code>를</code></p>
<pre>
<code>for($i=0; $row1=sql_fetch_array($result1); $i++){</code></pre>
<p><font face="monospace"><span style="font-size: 11.375px;">로 수정해 보세요.</span></font></p>
<p><font face="monospace"><span style="font-size: 11.375px;">
위 문제가 아니라면 오류 구문을 알려주세요.
답변에 대한 댓글 1개
댓글을 작성하려면 로그인이 필요합니다.
답변을 작성하려면 로그인이 필요합니다.
로그인
member에 it_maker 라는 컬럼도 만들어 놓은겁니다