高分求SQL语句

mustapha 2003-04-01 04:55:34
有一个数据库article,存放ArticleID,,name(文章名),bid(文章所属板块) 等等字段。第二个数据库reply,存放有ReplyID,ArticleID(与Article数据库的ArticleID相对应)
,另还有回复时间,回复人,回复主体等。第三个数据库board,存放BoardID,type(板块种类),name(板块名),banzhu(板块斑竹姓名)
temprs=conn.execute("select count(ArticleID) from article")可以计算article表中的记录数,那么我在同一页面想显示各板块的斑竹姓名、板块名、板块中的文章数和回复数,sql语句应该怎么写?
...全文
7 点赞 收藏 9
写回复
9 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
pengdali 2003-04-02
你不要改我写的呀!你后面少了括号!!

temprs4=conn.execute("select count(*) from reply where articleid in
(select articleid from article where bid='"&你的版块变量&"')");
----------------------------------------------------------^^^^这个括号你少了!
回复
mustapha 2003-04-01
前几句都对了,回复数不对:
Microsoft OLE DB Provider for ODBC Drivers 错误 '80040e14'

[Microsoft][ODBC Microsoft Access 驱动程序] 丢失 ), ], 或项目 在查询表达式 'articleID in(select ArticleID from article where bid='1'' 中
我的代码:temprs=conn.execute("select count(*) from reply where articleID in(select ArticleID from article where bid='1'")
回复
pengdali 2003-04-01
拆成几句


斑竹姓名:
temprs2=conn.execute("select banzhu from board where BoardID='"&你的版块变量&"'");

板块名:
temprs3=conn.execute("select name from board where BoardID='"&你的版块变量&"'");

板块中的文章数:
temprs4=conn.execute("select count(*) from article where bid='"&你的版块变量&"'");

回复数:
temprs4=conn.execute("select count(*) from reply where articleid in (select articleid from article where bid='"&你的版块变量&"')");
回复
mustapha 2003-04-01
调试不成功,都是“缺少case”
我不是要放在一句里,拆成几句也行。
回复
caiyunxia 2003-04-01
对楼上修改
SELECT banzhu, a.name, COUNT(b.articleid) , COUNT(c.ReplyID)
FROM board a left JOIN
articleb ON ON a.bid = c.bid
left JOIN
ReplyID c ON b.articleid = c.articleid
group by banzhu, a.name
回复
yoki 2003-04-01
SELECT c.banzhu, c.name, COUNT(a.articleid) AS Expr1, COUNT(b.replayid) AS Expr2
FROM article a INNER JOIN
reply b ON a.articleid = b.articleid INNER JOIN
board c ON a.bid = c.bid
回复
CrazyFor 2003-04-01
好象表名打错了,自己更正一下吧。
回复
CrazyFor 2003-04-01
TRY:

select a.*,(select count(*) from atricle where bid=a.boardid) as 文章数,
(select count(*) from replyId left join atricle on replyid.articleid=atricle.articleid where articleid.bid=a.boardid) as 回复数,
from board a
回复
CrazyFor 2003-04-01
你可分多个语句分别得到这些数据啊。
回复
相关推荐
发帖
疑难问题
创建于2007-09-28

2.1w+

社区成员

MS-SQL Server 疑难问题
申请成为版主
帖子事件
创建了帖子
2003-04-01 04:55
社区公告
暂无公告