Can you guys help me optimize this query. What's a more efficient way to do this?
SELECT *, (
SELECT COUNT(i开发者_如何学JAVAd) FROM post WHERE created > 1288953377 AND topic_id = topic.id
) AS post_today FROM topic
I guess this is what you need,
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
精彩评论