当前位置: 代码迷 >> Java Web开发 >> 请问!怎么实现 这样的查询?
  详细解决方案

请问!怎么实现 这样的查询?

热度:628   发布时间:2016-04-17 13:07:56.0
请教!如何实现 这样的查询???
小弟我想做一个论坛,可是遇到了,下面问题:
我有三个表:(sort)版面分类表、(topic)主题表、(response)回复主题表。
具体如下:

sort表:
----------------------------------
s_id s_name       master
----------------------------------

topic   表:
--------------------------------------------------
t_id s_id t_name U_name t_time t_content
--------------------------------------------------

response   表:
--------------------------------------------------
r_id t_id U_name r_content r_time
--------------------------------------------------


小弟我现在想查询:topic   表中的所有信息根据s_id   并查询每个主题所对应的回贴数。
就是这个问题我搞了好几天都没结果。
请问如何实现????

------解决方案--------------------
select count(*) from response where t_id=XXXXX
------解决方案--------------------
select a.*, b.count(*) from topic a, response b where a.t_id = b.t_id and a.s_id = ? group by t_id
  相关解决方案