是这样的 有个讨论模块 发帖主表 A
-----------------------------
A.id A.文章标题 A.发帖时间 A.发帖者
回贴表 B
-----------------------------------------
B.id 主表ID(A.id)B.回复内容 B.回复时间 B.回复人
现在想通过SQL语句实现这样的功能:在列表页中如何查出所有的发帖者和回复人,并统计总数?
谢谢老大们!
-----------------------------
A.id A.文章标题 A.发帖时间 A.发帖者
回贴表 B
-----------------------------------------
B.id 主表ID(A.id)B.回复内容 B.回复时间 B.回复人
现在想通过SQL语句实现这样的功能:在列表页中如何查出所有的发帖者和回复人,并统计总数?
谢谢老大们!
解决方案 »
- 社保基金审计,如何将补发记录拆解成每月一条记录?
- 还是关于备份DATABASE和LOG
- 请问这里,还没有Commit为什么会有@@ERROR啊
- 能不能禁止数据库用户用查询分析器远程登录我的MSSQL2000服务器呢
- 请教一个合并日期的函数
- server agent服务启动不了,给高分,但同时要告诉我怎么给你,是新客
- 在创建视图的SQL语句中可以判断当前系统日期吗?
- 高手帮忙,===存储过程执行结果和SQL执行结果不一致.===
- sql2000 删除列问题
- SQL脚本导入数据库后,数据出现乱码..郁闷一天了..
- 我的数据库名是mydata,如何测出数据库mydata的大小,SQL语句如何写?
- 求一SQL语句
所有的发帖者 select disticnt A.发帖者 from A
发帖者人数 select count(disticnt A.发帖者) from A
回复人 select disticnt B.回复人 from B
回复人人数 select count(disticnt B.回复人) from Bselect A.发帖者,B.回复人 from A inner join B on A.Aid = B.Aid
select count(disticnt A.发帖者),count(disticnt B.回复人) from A inner join B on A.Aid = B.Aid
from A join B on a.ID=b.AID
select 发帖者 from 发帖主表
union all
select 回复人 from 回贴表
union all
select cast(count(*) as varchar) 总数 from
(
select 发帖者 from 发帖主表
union all
select 回复人 from 回贴表
) t
select distinct 发帖者 from 发帖主表
union all
select distinct 回复人 from 回贴表
union all
select cast(count(*) as varchar) 总数 from
(
select 发帖者 from 发帖主表
union all
select 回复人 from 回贴表
) t
union all
select 回复人 from 回贴表 select @@rowcount