2012-09-23 4 views
0

도와주세요!MySQL 오류 그룹당 Re-at-

 SELECT ma_forum.*, ma_forum_cat.* 

     FROM ma_forum, ma_forum_cat 

     JOIN ma_forum_comentarios ON ma_forum_comentarios.not_id = ma_forum.not_id 

     GROUP BY ma_forum.not_id 

     WHERE ma_forum.notcat_id=ma_forum_cat.notcat_id AND ma_forum.notcat_id='".$notcat_id."' 

     AND ma_forum.not_status='Ativo' 

     ORDER BY MAX(ma_forum_comentarios.comnot_data) DESC 

"당신은 당신의 SQL 구문에 오류가 있습니다; 'WHERE ma_forum.notcat_id = ma_forum_cat.notcat_id 및 ma_forum.notcat_id ='1 근처 사용할 수있는 권리 구문에 대한 MySQL 서버 버전에 해당하는 설명서를 확인 ''9 번 줄에서 "

+1

GROUP BY에 대한 링크가 쿼리에 잘못된 장소에있다 : WHERE 후 BY ORDER 전에 GROUP BY가 있어야한다. 나는 ORDER BY 전후 어디서 왔다고 생각합니다. – andrewsi

+0

@andrewsi이 질문에 답변이 있어야합니다. – Petah

+0

올바른 구문을 찾아보기 전까지는 답변을 게시하고 싶지 않았습니다. GROUP BY 또는 ORDER BY가 먼저 오는지는 결코 기억할 수 없습니다. – andrewsi

답변

0

검색어의 순서가 잘못되었습니다. 난 당신이 사용중인 데이터베이스 모르는

SELECT ma_forum.*, ma_forum_cat.* 
FROM ma_forum, ma_forum_cat 
JOIN ma_forum_comentarios ON ma_forum_comentarios.not_id = ma_forum.not_id 
WHERE ma_forum.notcat_id=ma_forum_cat.notcat_id AND ma_forum.notcat_id='".$notcat_id."' 
AND ma_forum.not_status='Ativo' 
GROUP BY ma_forum.not_id 
ORDER BY MAX(ma_forum_comentarios.comnot_data) DESC 

, 그러나 여기 MySQL's SELECT syntax

+0

예! 지금 다른 오류가 있습니다. 'on 절'에 'ma_forum.not_id'열이 없습니다. –

+0

'ma_forum'테이블에 'not.id'라는 열이 있습니까? – andrewsi