$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개 / 댓글 5개
채택된 답변
+20 포인트
2017-07-05 (수) 12:54:01
union all select select count(*)
union all 다음에 select가 한 번 더 들어간 것 같은데 저건 오탄가요?
답변에 대한 댓글 5개
Jaeuk
2017-07-05 (수) 15:16:09
2017-07-05 (수) 15:21:20
근데 지금 쿼리문을 보면 단순히 count만 찍는데 저건 그냥 값 하나만 덜렁 나올 텐데 for로 돌리신 이유라도 있나요?
Jaeuk
2017-07-05 (수) 15:22:35
따로 이유는 없습니다.. 초보라서 결과값은 sum(total) 값 하나만 나오는데 그것만 따로 출력하는 방법을 몰라서요 ㅠㅠ
Jaeuk
2017-07-05 (수) 15:26:42
후... union all select select(*) 이 부분이 select가 두번 들어갓고 select count가 빠졌었네요 ..
일괄수정하다 실수를 범한것 같습니다..
일괄수정하다 실수를 범한것 같습니다..
Jaeuk
2017-07-05 (수) 15:28:22
$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];
답변참고하여 해결했습니다 ㅎ 감사합니다
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];
답변참고하여 해결했습니다 ㅎ 감사합니다
답변을 작성하려면 로그인이 필요합니다.
echo "hello"; 로 확인해봤더니 for문이 작동을 안합니다..ㅠ