안녕하세요.
관리자 화면에서 회원총수는 있는데 남자와 여자 회원의 수를 따로 보여주고싶습니다.
일전에 문의를 드려 아래와 같은 답을 받았습니다.
그런데 오류가 나오는데 어떻게 처리를 해야 할지 몰라 질문드립니다.
$chk=sql_fetch(" SELECT SUM(IF(mb_sex == F,1,0)) as tot_man_cnt, SUM(IF(mb_sex == M,1,0)) as tot_woman_cnt WHERE $g4[member_table] ");
----오류---
SELECT SUM(IF(mb_sex == F,1,0)) as tot_man_cnt, SUM(IF(mb_sex == M,1,0)) as tot_woman_cnt WHERE g4_member
1064 : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '== F,1,0)) as tot_man_cnt, SUM(IF(mb_sex == M,1,0)) as tot_woma
error file : /adm/member_list.php
관리자 화면에서 회원총수는 있는데 남자와 여자 회원의 수를 따로 보여주고싶습니다.
일전에 문의를 드려 아래와 같은 답을 받았습니다.
그런데 오류가 나오는데 어떻게 처리를 해야 할지 몰라 질문드립니다.
$chk=sql_fetch(" SELECT SUM(IF(mb_sex == F,1,0)) as tot_man_cnt, SUM(IF(mb_sex == M,1,0)) as tot_woman_cnt WHERE $g4[member_table] ");
----오류---
SELECT SUM(IF(mb_sex == F,1,0)) as tot_man_cnt, SUM(IF(mb_sex == M,1,0)) as tot_woman_cnt WHERE g4_member
1064 : You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '== F,1,0)) as tot_man_cnt, SUM(IF(mb_sex == M,1,0)) as tot_woma
error file : /adm/member_list.php
|
댓글을 작성하시려면 로그인이 필요합니다.
댓글 3개
SUM( CASE mb_sex WHEN 'F' THEN 1 ELSE 0 END ) as tot_man_cnt,
SUM( CASE mb_sex WHEN 'M' THEN 1 ELSE 0 END ) as tot_woman_cnt
FROM $g4[member_table]
$man=sql_fetch("select count(*) as cnt from $g4[member_table] where mb_sex='M'");
echo $man[cnt]; //남자회원
echo $total_count - $man[cnt]; //여성회원
//////////////
SELECT SUM(IF(mb_sex == F,1,0)) as tot_man <---여기 에러는 쿼리구문이 틀렷습니다
아래처럼..
SELECT SUM(IF(mb_sex ='M',1,0)) as tot_man_cnt, SUM(IF(mb_sex ='F',1,0)) as tot_woman_cnt from $g4[member_table]
균이님이 주신 답으로 해결했습니다. 감사합니다.