MySQL错误Greatest-n-per-group

时间:2012-09-23 21:21:19

标签: mysql greatest-n-per-group

    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

'on clause'

中的未知列'ma_forum.not_id'

1 个答案:

答案 0 :(得分:0)

not_id表中不存在列ma_forum

如果列确实存在,请尝试以下操作并向后报告。

SELECT ma_forum.*, 
       ma_forum_cat.*
FROM   ma_forum JOIN 
       ma_forum_cat ON ma_forum.notcat_id = ma_forum_cat.notcat_id JOIN 
       ma_forum_comentarios ON ma_forum_comentarios.not_id = ma_forum.not_id
WHERE  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