table_forum
|id_forum|name_forum|
| 1 |forum 1 |
| 2 |forum 2 |
表格线程
|id_thread|name_thread|id_forum|
| 1 |thread 1 | 1 |
| 2 |thread 2 | 1 |
我需要一个返回
的查询|name_forum|thread|
| forum 1 | 2 |
| forum 2 | 0 |
你能帮帮我吗?
答案 0 :(得分:0)
如果他们是两张桌子,我想这样试试
select table_forum.name_forum,count(table_thread.id_forum) from table_thread join table_forum where table_form.id_forum = table_thread.id_forum group by table_thread.id_forum