0
我需要获得个帖子的编号不是主题,其中forum_id = 1。这甚至有可能吗?我想我必须使用连接,但这对我来说似乎难以置信。加入两张表并获得行数
topics:
id | title | forum_id
posts:
id | message | topic_id
我需要获得个帖子的编号不是主题,其中forum_id = 1。这甚至有可能吗?我想我必须使用连接,但这对我来说似乎难以置信。加入两张表并获得行数
topics:
id | title | forum_id
posts:
id | message | topic_id
SELECT COUNT(*) FROM posts JOIN topics t ON (topic_id = t.id) WHERE forum_id = 1
与主题
select distinct count(p.id) from posts p inner join topics t on p.topic_id = t.id
where t.forum_id = 1
group by p.id
职位数