db를 불러올때말이지요.. > 개발자팁

개발자팁

개발과 관련된 유용한 정보를 공유하세요.
질문은 QA에서 해주시기 바랍니다.

db를 불러올때말이지요.. 정보

PHP db를 불러올때말이지요..

본문

<?
    $qry = "SELECT op_pcode,sum(op_cnt) as cnt
            FROM view_order where paystatus = 'Y'
            and canceled = 'N'
            and ifnull(isNow,'N') = 'Y'
            group by op_pcode
            order by cnt desc limit 10";
 

    $rlt = mysql_query($qry);
    while($row = mysql_fetch_array($rlt)) {
        $pcode = $row['op_pcode']; 
        $pcnt = $row['cnt']; 
        //상품명
        $prslt =  mysql_fetch_array(mysql_query("select name,cateCode,price_org,price,saleCnt from odtProduct where code='".$pcode."'"));
        $pname = $prslt[name];
        $price_org = $prslt[price_org];
        $price = $prslt[price];
        $pcatecode = $prslt[cateCode];
  $psalecnt = $prslt[saleCnt];
        //카레고리명
        $pcatename =  mysql_result(mysql_query("select catename from odtCategory where catecode='".$pcatecode."'"),0);
?>
 
 
이것들이 다 무슨 말이지요?? 저는 디비 안에 있는   [saleCnt] 라는 디비값만 가져오고 싶은데...
 
저 위의 구문이 해석이 안되니 힘드네요 ..
 
빨간색 구문은 특히 이해가 안갑니다 무슨 설정 값인지..
 
아래부분은 대충 이해는 했습니다만 ㅠㅠ
 
 
해석해주실 능력자분 계신가요?
추천
0
  • 복사

댓글 3개

SELECT  검색해라
op_pcode,sum(op_cnt) as cnt  를
 FROM view_order  이테이블에서
where paystatus = 'Y'
            and canceled = 'N'
            and ifnull(isNow,'N') = 'Y'
조건은 지불상태가y이면서 취소하지 않은것을 그리고 isnow 상태가 비어있다면 n으로 바꿔라 그 isnow 가 y 인조건으로

            group by op_pcode
그결과를 op_pcode 로 묵어라

 order by cnt desc
 소팅하라 cnt가 높은순으로
 limit 10
그중 10개만 출력하라 정도 되겠습니다
© SIRSOFT
현재 페이지 제일 처음으로