간단한 쿼리문 결과 왜 실행이 안될까요...;

간단한 쿼리문 결과 왜 실행이 안될까요...;

QA

간단한 쿼리문 결과 왜 실행이 안될까요...;

본문

$total_row_sql = "select sum(total) from (

select count(*) as total from {$g5['write_locationboard_table']} where wr_is_comment != 1

union all select select(*) as total from {$g5['write_used_market_table']} where wr_is_comment != 1

union all select select(*) as total from {$g5['write_schedule_table']} where wr_is_comment != 1) tb";


$teli = array();

$total_row = mysqli_query($link, $total_row_sql);

for($i=0; $total_row_result=mysqli_fetch_array($total_row); $i++){

    $teli[$i] = $total_row_result;

    echo print_r($teli[$i]);

}

$rows = 13; // 목록수


쿼리문은 mysql에서 제대로 작동하는데요..

계속 이렇게 쓰고 있었는데 왜 이것만 안될까요..

저 쿼리문의 결과가 하나라서 안나오는 건가요??

이 질문에 댓글 쓰기 :

답변 1

union all select select count(*)

union all 다음에 select가 한 번 더 들어간 것 같은데 저건 오탄가요?

$total_sql = "select sum(total) from (
select count(*) as total from {$g5['write_locationboard_table']} where wr_is_comment != 1
union all select count(*) as total from {$g5['write_used_market_table']} where wr_is_comment != 1
union all select count(*) as total from {$g5['write_schedule_table']} where wr_is_comment != 1) tb";
$teli = array();
$total_row = mysqli_query($link, $total_sql);
$total_result = mysqli_fetch_array($total_row);
echo $total_result[0];

답변참고하여 해결했습니다 ㅎ 감사합니다

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

회원로그인

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