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

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

QA

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

답변 1

본문

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

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

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 25
© SIRSOFT
현재 페이지 제일 처음으로