Mysql语句,请问错在哪里? SELECT topic.*, 
   COUNT (retopic.topic_id) AS recount, 
  MAX (if(re_posttime,re_posttime,posttime)) AS newtime
  FROM topic LEFT JOIN retopic  
  On topic.topic_id =retopic.topic_id  
  GROUP BY topic.topic_id, forum.topic
  ORDER BY newtime DESC

解决方案 »

  1.   

    SELECT topic.topic_id, forum.topic,
      COUNT (retopic.topic_id) AS recount,
      MAX (if(re_posttime,re_posttime,posttime)) AS newtime
      FROM topic LEFT JOIN retopic 
      On topic.topic_id =retopic.topic_id 
      GROUP BY topic.topic_id, forum.topic
      ORDER BY newtime DESC
    你的SQL语句不是标准的SQL格式
      

  2.   

    topic.* 多行
    max() 单行
    count() 单行
    这些怎么放到一起??
      

  3.   

    MAX (if(re_posttime,re_posttime,posttime)) 有错
    你的sql语句很乱。
      

  4.   

    已经知道错在哪里!
    COUNT (retopic.topic_id) AS recount, 
    MAX (if(re_posttime,re_posttime,posttime)) AS newtime 
    有错!
    Thanks!