2012-09-23 35 views
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錯誤最大正每組

+0

該列在表別名'ma_forum'表示的表中不存在。除此之外,沒有任何信息可以幫助您。 –

+2

停止混合隱式(逗號分隔表)和顯式連接。你使用兩個內部連接,所以使用兩個適當的'JOIN'並從WHERE子句中刪除第一個隱式連接條件。 –

+0

這是你的其他問題的重複。同一主題。 http://stackoverflow.com/questions/12555413/order-by-in-other-table#comment16910497_12555413 – ApplePie

回答

0

not_id不在ma_forum表中存在「ma_forum.not_id」。

如果該列確實存在,請嘗試以下操作並回報。

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 
+0

存在!錯誤在語法中。 –

+0

YEEEEEEEEEEEEEEEES!謝謝! –