mysql select로 여러 조건을 한번에 검색 정보
mysql select로 여러 조건을 한번에 검색
본문
안녕하세요.
mysql 질문입니다.
lecture_booktype 각 항목 별로 누적 합계를 구하고자 합니다.
lecture_booktype이 1인것 x개, 2인것 y개 이런식으로 하려고 하는데요.
SELECT count(`id`) as cnt1 FROM `cukin_lecture_evaluation` WHERE `lecture_booktype`= '1';
SELECT count(`id`) as cnt2 FROM `cukin_lecture_evaluation` WHERE `lecture_booktype`= '2';
이렇게 쿼리를 두번 날려도 되지만, 한번에 할 수 있는 방법이 있는지 궁금해서 질문드립니다.
mysql 질문입니다.
lecture_booktype 각 항목 별로 누적 합계를 구하고자 합니다.
lecture_booktype이 1인것 x개, 2인것 y개 이런식으로 하려고 하는데요.
SELECT count(`id`) as cnt1 FROM `cukin_lecture_evaluation` WHERE `lecture_booktype`= '1';
SELECT count(`id`) as cnt2 FROM `cukin_lecture_evaluation` WHERE `lecture_booktype`= '2';
이렇게 쿼리를 두번 날려도 되지만, 한번에 할 수 있는 방법이 있는지 궁금해서 질문드립니다.
댓글 전체

select distinct lecture_booktype, count(lecture_booktype) as cnt from cukin_lecture_evaluation group by ecture_booktype

오, 잘 되네요. 고맙습니다.