我是要在一个页面显示关联的两个表,怎么办?

来源:百度知道 编辑:UC知道 时间:2024/06/14 07:37:34
如题,我不知道怎么关联两个表?各位大侠帮忙看看,下面的代码得出rs1的结果都是第一个记录的,没和rs的结果关联上,代码如下:

<form id="form1" name="form1" method="POST">
<p align=center><font style='FONT-SIZE:12pt' color=red><b> 客 户 合 同 管 理</b></font></p>
<table align=center border='0' width='100%'>
<tr>
<td align='left'>全部收款情况
<%
Dim rs,rsCate
Set rs = Server.CreateObject("ADODB.RecordSet")
Set rs1 = Server.CreateObject("ADODB.RecordSet")
set rsCate = Server.CreateObject("ADODB.RecordSet")
'定义变量
%>
</td>

</tr>
</table>

<table align=center border="1" cellspacing="0" width="100%" bgcolor="#F0F8FF" bordercolorlight="#4DA6FF" bordercolorda

你应该把两张表的结构写出来.
估计你的表设计如下:

kehuhetong 表的信息应该有hetongname,
caiwu 是对各个合同的收款信息.
用一条查询语句:
select kehuhetong.*, caiwu.*
from kehuhetong,caiwu
where kehuhetong.htongname=caiwu.caiwuname

有问题
1. for循环在哪儿?没看见啊
2. 连接两个表,除了楼上的,还可以用join
select *
from kehuhetong left join caiwu on kehuhetong.htongname=caiwu.caiwuname
当然要求kehuhetong.htongname和caiwu.caiwuname 一样才行