| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 413 人关注过本帖
标题:[求助]SQL
只看楼主 加入收藏
yonyon275
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-10-26
收藏
 问题点数:0 回复次数:2 
[求助]SQL
<%
sql = "select *,ShowTime = convert(char(20),CreateDate,120) from TArticle where IfCommand = 'Y' and IfIssue = 'Y' and ArtType <> '004' order by CreateDate desc"
set rs = conn.execute(sql)
ShowTime = rs("ShowTime")
i = 0
do while not rs.eof and i<11
select case rs("ArtType")
case "000"
sql = "select * from TArticleInformation where ArticleId = '"+rs("ArticleId")+"'"
set rsInf = conn.execute(sql)
if not rsInf.eof then
sTitle = rsInf("Title")
Information = "标题:"+rsInf("Title")+" 作者:"+rsInf("Auther")+" 发布时间:"+ShowTime+" 点击率:"+cstr(rs("ClickNum"))
end if
rsInf.close
case "001"
sql = "select * from TLibrary where ArticleId = '"+rs("ArticleId")+"'"
set rsInf = conn.execute(sql)
if not rsInf.eof then
sTitle = rsInf("Title")
Information = "标题:"+rsInf("Title")+chr(13)+"作者:"+rsInf("Auther")+chr(13)+"发布时间:"+ShowTime+chr(13)+"点击率:"+cstr(rs("ClickNum"))
end if
rsInf.close
case "002"
sql = "select * from TCultural where ArticleId = '"+rs("ArticleId")+"'"
set rsInf = conn.execute(sql)
if not rsInf.eof then
sTitle = rsInf("Title")
Information = "标题:"+rsInf("Title")+chr(13)+"发布时间:"+ShowTime+chr(13)+"点击率:"+cstr(rs("ClickNum"))
end if
rsInf.close
case "003"
sql = "select * from TDynamic where ArticleId = '"+rs("ArticleId")+"'"
set rsInf = conn.execute(sql)
if not rsInf.eof then
sTitle = rsInf("Title")
Information = "标题:"+rsInf("Title")+chr(13)+"作者:"+rsInf("Auther")+chr(13)+"发布时间:"+ShowTime+chr(13)+"点击率:"+cstr(rs("ClickNum"))
end if
rsInf.close
end select
%>

哪位大虾解释下哦 谢谢咯?
搜索更多相关主题的帖子: SQL 
2006-11-06 13:27
mbranch
Rank: 1
等 级:新手上路
帖 子:12
专家分:0
注 册:2006-10-17
收藏
得分:0 
不会……

……
2006-11-06 13:54
小海龟
Rank: 6Rank: 6
等 级:贵宾
威 望:23
帖 子:1068
专家分:4
注 册:2006-8-1
收藏
得分:0 

把文章表中的所有字段查询出来以及字定义的ShowTime字段,转换有不懂的看:http://fengyu.china.com/sqlserver_datefmt.htm
查询条件:IfCommand = 'Y' 和IfIssue = 'Y' 和ArtType <> '004'按CreateDate降序排序.
变量i=0
如果数据表中不为空且i<11
如果:ArtType="000":
给sTitle,Information 赋值
......
select 的后面你找下肯定有i=i+1循环用的,也就是在这个结构中要查出11条记录(sTitle,Information)

asp的代码,到asp区去发.


[bc09] 犯强汉者,虽远比诛!
2006-11-06 14:50
快速回复:[求助]SQL
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016217 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved