吉田松阴 辞世诗:这个ASP代码什么意思

来源:百度文库 编辑:中科新闻网 时间:2024/04/30 15:40:21
sqlNew="select top 10 A.ArticleID,A.Title,A.Author,A.UpdateTime,A.Hits,L.LayoutFileName from article A inner join Layout L on L.LayoutID=A.LayoutID where A.Deleted=False and A.Passed=True order by A.articleid desc

它这个A.和L.是什么意思啊?自定义的表的别名,还是就是表名的第一个字母???

还有,这段代码是实现什么功能??

请详细解一下
article A inner join Layout L on L.LayoutID=A.LayoutID

这是什么意思?
那么他这样最后的输出结果会是什么啊???

是不是会把两个表合成一个表?
并且,相同字段只保留一个???

A指的是 article 表;L指 Layout 表,
这是为了简洁其间给表起了个别名。

article A inner join Layout L on L.LayoutID=A.LayoutID
A表与L表做自然连接,L.Layout与A.Layout做广义卡迪尔积,如果相等则将L中的记录连接到A后。

建立网站用的数据库软件

给你个参考下

sub ShowSearchResult()
dim arrClassID,trs
sqlSearch=sqlSearch & "select A.ArticleID,A.ClassID,L.LayoutID,L.LayoutFileName,A.Title,A.Key,A.Author,A.CopyFrom,A.UpdateTime,A.Editor,A.TitleFontColor,A.TitleFontType,A.Content,"
sqlSearch=sqlSearch & "A.Hits,A.OnTop,A.Hot,A.Elite,A.Passed,A.IncludePic,A.Stars,A.PaginationType,A.ReadLevel,A.ReadPoint,A.DefaultPicUrl from Article A"
sqlSearch=sqlSearch & " inner join Layout L on A.LayoutID=L.LayoutID where A.Deleted=False and A.Passed=True"
if ClassID>0 then
if Child>0 then
arrClassID=ClassID
if ParentID>0 then
set trs=conn.execute("select ClassID from ArticleClass where ParentID=" & ClassID & " or ParentPath like '%" & ParentPath & "," & ClassID & ",%' and Child=0 and LinkUrl='' and BrowsePurview>=" & UserLevel)
else
set trs=conn.execute("select ClassID from ArticleClass where RootID=" & RootID & " and Child=0 and LinkUrl='' and BrowsePurview>=" & UserLevel)
end if
do while not trs.eof
arrClassID=arrClassID & "," & trs(0)
trs.movenext
loop
set trs=nothing
sqlSearch=sqlSearch & " and A.ClassID in (" & arrClassID & ")"
else
sqlSearch=sqlSearch & " and A.ClassID=" & ClassID
end if
end if
if keyword<>"" then
select case strField
case "Title"
sqlSearch=sqlSearch & " and A.Title like '%" & keyword & "%' "
case "Content"
sqlSearch=sqlSearch & " and A.Content like '%" & keyword & "%' "
case "Author"
sqlSearch=sqlSearch & " and A.Author like '%" & keyword & "%' "
case "Editor"
sqlSearch=sqlSearch & " and A.Editor like '%" & keyword & "%' "
case else
sqlSearch=sqlSearch & " and A.Title like '%" & keyword & "%' "
end select
end if
sqlSearch=sqlSearch & " order by A.Articleid desc"
Set rsSearch= Server.CreateObject("ADODB.Recordset")
rsSearch.open sqlSearch,conn,1,1
if rsSearch.eof and rsSearch.bof then
totalput=0
response.write "<p align='center'><br><br><img src='pic1/1.gif' width='20' height='20'><font color='#B3221F'><strong> 非常抱歉!系统没有找到符合您要求的任何文章,请更改查询条件再试。</stong></font></p>"
else
totalput=rsSearch.recordcount
if currentpage<1 then
currentpage=1
end if
if (currentpage-1)*MaxPerPage>totalput then
if (totalPut mod MaxPerPage)=0 then
currentpage= totalPut \ MaxPerPage
else
currentpage= totalPut \ MaxPerPage + 1
end if
end if
if currentPage=1 then
call SearchResultContent()
else
if (currentPage-1)*MaxPerPage<totalPut then
rsSearch.move (currentPage-1)*MaxPerPage
dim bookmark
bookmark=rsSearch.bookmark
call SearchResultContent()
else
currentPage=1
call SearchResultContent()
end if
end if
end if
rsSearch.close
set rsSearch=nothing
end sub

sub SearchResultContent()
dim i,strTemp,content
i=1
do while not rsSearch.eof
strTemp=""
strTemp=strTemp & cstr(MaxPerPage*(CurrentPage-1)+i) & ".<a href='" & rsSearch("LayoutFileName") & "?ArticleID=" & rsSearch("articleid") & "'>"
if strField="Title" then
strTemp=strTemp & "<b>" & replace(rsSearch("title"),""&keyword&"","<font color=red>"&keyword&"</font>") & "</b></font></a>"
else
strTemp=strTemp & "<b>" & rsSearch("title") & "</b>"
end if
if strField="Author" then
strTemp=strTemp & " [" & replace(rsSearch("Author"),""&keyword&"","<font color=red>"&keyword&"</font>") & "]"
else
strTemp=strTemp & " [" & rsSearch("Author") & "]"
end if
strTemp=strTemp & "[" & FormatDateTime(rsSearch("UpdateTime"),1) & "][" & rsSearch("Hits") & "]"
content=left(replace(replace(nohtml(rsSearch("content")), ">", ">"), "<", "<"),200)
if strField="Content" then
strTemp=strTemp & "<div style='padding:10px 20px'>" & replace(content,""&keyword&"","<font color=red>"&keyword&"</font>") & "……</div>"
else
strTemp=strTemp & "<div style='padding:10px 20px'>" & content & "……</div>"
end if
strTemp=strTemp & "</a>"
response.write strTemp
i=i+1
if i>MaxPerPage then exit do
rsSearch.movenext
loop
end sub

article A inner join Layout L on L.LayoutID=A.LayoutID
就是同时查寻两个变,A和L都是自定义的
打开article这个表,同时在打开
Layout里边LayoutID字段等于article里的LayoutID
同常都是调用分类名时用
比如打开的是文章表里的分类为1
则同时打开分类表里分类ID等1的

A和L是为了简洁其间给表起了个别名。