테이블 4개 조인, COUNT함수 0 2 3,420

by NEOCAN MYSQL COUNT CARTISIENT PRODUCT [2016.08.20 03:30:24]


SELECT COUNT(A.MB_NICK) AS SHOWCOUNT
     , COUNT(B.MB_NICK) AS REPLY
     , COUNT(C.MB_NICK) AS LIKEE
     , COUNT(D.MB_NICK) AS HATE
  FROM RA_SHOW_COUNT_TB A
     , RA_REPLY_TB B
     , RA_PREFERENCE_TB C
     , RA_HATE_TB D
  WHERE A.ST_ROWID = 96
    AND A.ST_ROWID = B.ST_ROWID
    AND A.ST_ROWID = C.ST_ROWID
    AND A.ST_ROWID = D.ST_ROWID;

 

 

여기서 결과값이 카티션프로덕트가 발생한건지 이상하게 나오더라구요. ㅠㅠㅠ 

저 테이블의 카운트값을 곱한값이 나와요 ㅠㅠ

 

뭐가문제인지 알려주세요 ㅠㅠ 

by 손님 [2016.08.20 22:25:56]
SELECT COUNT(A.MB_NICK) AS SHOWCOUNT
, COUNT(B.MB_NICK) AS REPLY
, COUNT(C.MB_NICK) AS LIKEE
, COUNT(D.MB_NICK) AS HATE
FROM RA_SHOW_COUNT_TB A
, RA_REPLY_TB B
, RA_PREFERENCE_TB C
, RA_HATE_TB D
WHERE A.ST_ROWID = 96
AND A.ST_ROWID = B.ST_ROWID
AND A.ST_ROWID = C.ST_ROWID
AND A.ST_ROWID = D.ST_ROWID;

조건절에 조인조건을 바꿔보시는게 어떨지요
WHERE A.ST_ROWID = B.ST_ROWID
AND B.ST_ROWID = C.ST_ROWID
AND C.ST_ROWID = D.ST_ROWID
AND A.ST_ROWID = 96;
테이블에 들어가 있는정보랑 테스트를 해봐야지 정확히 알겠지만요

by 마농 [2016.08.22 10:41:27]
SELECT COUNT(mb_nick) FROM ra_show_count_tb WHERE st_rowid = 96) AS showcount
     , COUNT(mb_nick) FROM ra_reply_tb      WHERE st_rowid = 96) AS reply    
     , COUNT(mb_nick) FROM ra_preference_tb WHERE st_rowid = 96) AS likee    
     , COUNT(mb_nick) FROM ra_hate_tb       WHERE st_rowid = 96) AS hate     
  FROM dual
;

 

댓글등록
SQL문을 포맷에 맞게(깔끔하게) 등록하려면 code() 버튼을 클릭하여 작성 하시면 됩니다.
로그인 사용자만 댓글을 작성 할 수 있습니다. 로그인, 회원가입