你们可以帮我优化这个查询吗?有什么更有效的方法呢?
SELECT *, (
SELECT COUNT(id) FROM post WHERE created > 1288953377 AND topic_id = topic.id
) AS post_today FROM topic
答案 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