##给分:两个表,如何用一个Select同时查询两个表的某些字段,并且查询后可以同时按行读出???见内!!

user 表的signature,face字段[用户]

和guestbook表的 title,content字段,[留言板]

两个表格,因为在留言版要调用user的头像face字段.

所以,我想通过一个SQL,查询出来.

这样就能用do until rs.eof来一次循环用表格格式后输出并分页了.

请教各位,请帮忙.保证给分!

---------------------------------------------------------------

可以的

SELECT user.signature,user.face,guestbook.title,guestbook.content FROM [user] INNER JOIN [guestbook] ON user.username=guestbook.username order by ...."

ON user.username=guestbook.username 是用来保证查询的是留言人(username)的对应信息

username是我写的,你的可能不一样。还有user是SQL保留字,还是使用其他的好一点
---------------------------------------------------------------

SELECT A.title,A.content,B.signature,B.face
FROM guestbook AS A INNER JOIN user AS B
ON A.User_ID = B.User_ID
WHERE .........

---------------------------------------------------------------

cpp2017(慕白兄) ::
你的有问题

:vb 运行时错误,错误的标记
某行某列

select a.a,b,c,b.a,d,e from a,b where a.a=b.a

---------------------------------------------------------------

这要看你的数据库设计的合理没有,就是要保证表guestbook跟user有相关连的字段,如USERID\guestbookid等。
然后查询起来很方便:
select user.face,user.signature,guestbook.title,guestbook.content
from user,guestbook where user.UserID = guestbook.guestbookid

Published At
Categories with Web编程
comments powered by Disqus