ASP显示关联数据表的问题,难啊~~

来源:百度知道 编辑:UC知道 时间:2024/05/22 16:41:03
我在ACCESS里面有两个表,一个表是存放注册会员的信息数据表,表名为USER
一个表是存放会员发的帖子的表,表名为NEWS

我想在TEST.ASP页面中指定某个地方只显示:USER表下ID字段编号为17,USER表下NAME字段为AA 这个用户发的存在于NEWS表下的TITLE字段中的内容,如何做到?

劳烦哪位大侠详细解释一下:是否需要做关联表的字段数据关联?ASP下该如何写才能正常显示?
我做了USER表下的ID与NEWS表下的TITLE关联,ASP里写
<%
sql="SELECT news.title from user,usernews where user.name = news.user and user.user = 'bloodyoung'"
rs.open sql,conn,1,1
if rs.recordcount=0 then
response.write "暂无资料"
else
while not rs.eof
%>

但是怎么弄都是错的

select [title] from news where user='bloodyoung';
不就可以了?
当然了,前提是news.user的是和user.user是一致的。

ms你没有把数据表结构说清楚,我看好像是这样的
//-----------------
[user]表
id
name
//-----------------
[news]表
id
title
userid

所以sql写成
select news.title from news,user where news.userid=user.id and user.name='bloodyoung';

sql="SELECT news.title from user,usernews where user.name = news.user and user.user = 'bloodyoung'"
貌似应该是:
sql="SELECT news.title from user,news where user.name = news.user and user.user = 'bloodyoung'"

检查一下字段名称

既然有id,为什么用user.user = 'bloodyoung'而不用user.id = 17呢 主键就是用来做这个事情的.