优化论坛查询

时间:2010-11-07 05:02:40

标签: mysql query-optimization

你们可以帮我优化这个查询吗?有什么更有效的方法呢?

SELECT *, ( 
         SELECT COUNT(id) FROM post WHERE created > 1288953377 AND topic_id = topic.id
    ) AS post_today FROM topic

1 个答案:

答案 0 :(得分:0)

我想这就是你需要的,

SELECT Col1,Col2,Col3, Count(id) from Topic 
LEFT JOIN post on topic_id = topic.id
where created > 1288953377
group by id,Col1,Col2,Col3