0

表论坛

|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   |

你能帮我吗?

4

1 回答 1

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
于 2012-09-19T05:29:40.860 回答