두 테이블 비교... 채택완료
A 게시판과 B게시판을 비교하고 싶습니다.
g5_write_buy 게시판은 물품 구입, g5_write_sell게시판은 물건 판매게시판입니다.
현재 아래와 같은 코드로 구입, 판매의 순위를 매기고 있습니다.
<table>
<colgroup>
<col width="50px">
<col width="100px">
<col width="60px">
<col width="*">
<col width="100px">
</colgroup>
<thead>
<tr>
<th>순위</th>
<th>총판장</th>
<th>고객수</th>
<th>판매품목</th>
<th>총 판매금액</th>
</tr>
</thead>
<tbody>
<?
$write_table = $g5['write_prefix'] . $bo_table;
$sum_count = "0";
$sql = "
select a.mb_id, b.mb_name, group_concat(wr_12 separator '||') wr_12, count(*) as cnt , sum(a.wr_31) as tot
from g5_write_sell a
left outer join {$g5['member_table']} b on a.mb_id = b.mb_id
where wr_29 between '{$stx1}' and '{$stx2}' and wr_50 like '%{$stx7}%'
group by a.mb_id, b.mb_name ORDER BY tot DESC
";
$result = sql_query($sql);
while ($row = sql_fetch_array($result)) {
$list_name = explode('||',$row['wr_12']);
sort($list_name); // 정렬
$num = array_count_values($list_name);</p>
<p> $sum_count ++
?></p>
<p> <tr>
<td class="td_c"><?php echo $sum_count ?>위</td>
<td class="td_c"><?php echo $row['mb_name'] ?></td>
<td class="td_c"><?php echo $row['cnt'] ?> 명</td>
<td class="td">
<?php foreach( $num as $key => $value ){ ?>
<?php echo $key; ?>(<?php echo $value?>),
<?php } ?></td>
<td class="td_r"><?php echo number_format($row['tot']) ?>원</td>
</tr>
<?php } ?>
</table>
구매, 판매의 순위 소스는 거의 비슷한 소스로 사용중입니다. 게시판명과 검색 부분값만 약간 틀려서 한개만 올렸습니다. wr_29은 날짜검색, wr_12은 제품목록[배열], wr_31은 총 합계금액입니다.
만들고 싶은건... 각각이 아닌 하나로 합치고 싶습니다. A라는 총판장이 g5_write_buy에서 먼저 구매를 한 후에 z라는 고객에게 물건을 판매 g5_write_sell 합니다.
판매금액(g5_write_sell) 옆에 구매금액(g5_write_buy)을 넣고 싶은데 구글링을 해보고 이것저것 다 해봐도 오류만 나고 뭐가 되질 않네요
항상 도와달라는 글만 올리는 거 같아서 죄송합니다.
댓글을 작성하려면 로그인이 필요합니다.
답변 2개
답변을 작성하려면 로그인이 필요합니다.
로그인전체 질문 목록
답변대기
답변대기
답변대기
답변대기
답변대기
답변대기
답변대기
답변대기
채택
답변대기
답변대기
답변대기
답변대기
채택
채택
답변대기
답변대기
답변대기
채택
값이 아무것도 나오질 않아서 이렇게 질문을 했습니다.
from 뒤에 INTERSECT, in 값 등등을 넣어서 테스트 중인데 뭐라도 값이 나오면 좀 더 해볼텐데 값이 아무것도 나오질 않습니다.