sql 两表查询语句问题

[复制链接]
查看11 | 回复1 | 2008-12-20 21:34:58 | 显示全部楼层 |阅读模式
下面是新闻查询代码
'' order by inputtime desc"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
if rs.eof then
response.write"暂无推荐图片新闻!"
else
do while not rs.eof
response.write"[url=]
[img][/img]
"
if len(rs("title"))>12 then
response.write""&left(rs("title"),10)&""
else
response.write""&rs("title")&""
end if
response.write"[/url]"
response.write""
rs.movenext
loop
end if
%>
上面的代码能够查询到最新新闻数据,但是连接的文件名确在另外一个表中,应该要怎么样写查询代码呢?才能够使连接地址正常连接?
新闻表
id,Title,Photo
新闻文件名在另外一个表中!比如在B表,字段:xwwj
这样才能够得到那个连接地址中的新闻文件名?
两个表有个相关连的字段:新闻表:channelid B表:channelid

回复

使用道具 举报

千问 | 2008-12-20 21:34:58 | 显示全部楼层
select a.id,a.Title,a.Photo,b.xwwj from a,b where a.channelid=b.id and a.channelid=? order by a.inputtime desc...
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行