sql 连接和计数
假设我有这个查询,
SELECT ft.*, m.*
FROM forum_topics ft
INNER JOIN members m ON ft.author = m.id
WHERE ft.forum = '$forum'
ORDER BY ft.lastpost DESC
我还想从表 forum_replies
中获取行计数,其中 id = ft.id
。 我怎么能这么做呢?
Say I have this query
SELECT ft.*, m.*
FROM forum_topics ft
INNER JOIN members m ON ft.author = m.id
WHERE ft.forum = '$forum'
ORDER BY ft.lastpost DESC
I want to also get a row count in that from the table forum_replies
where the id = ft.id
.
How could I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据您的数据库实现,这可能有效:
HTH
Depending on your DB implementation this might work:
HTH