관리자 화면에서 남여회원수 나타내기 질문드립니다. 정보
관리자 화면에서 남여회원수 나타내기 질문드립니다.본문
안녕하세요.
관리자 화면에서 회원총수는 있는데 남자와 여자 회원의 수를 따로 보여주고싶습니다.
일전에 문의를 드려 아래와 같은 답을 받았습니다.
그런데 오류가 나오는데 어떻게 처리를 해야 할지 몰라 질문드립니다.
$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
댓글 전체
SELECT
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]
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]
$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]
답변주신분들 모두 감사합니다.
균이님이 주신 답으로 해결했습니다. 감사합니다.
균이님이 주신 답으로 해결했습니다. 감사합니다.