简单问题;Access 有两个表在一个页面的查询和显示
各位大侠,这是一个简单问题,请赐教。Access 有两个表,表1: A;表2:B。结构如下:
表A:
字段 A.ID;A.City
表B:
字段 B.ID;A.Name
它们的关系:A.ID=B.ID
---------------------------------------------------------------
我要实现的显示结果:
A.ID1 A.City1
B.ID1 B.Name1
B.ID1 B.Name2
B.ID1 B.Name3
A.ID2 A.City2
B.ID2 B.Name4
B.ID2 B.Name5
A.ID3 A.City3
B.ID3 B.Name6
............
------------------------------------------
但我现在通过Dreamweaver的记录集显示的结果如下:
A.ID1 A.City1
A.ID2 A.City2
A.ID3 A.City3
。。。。。
------------------------------
我的问题是如何创建查询,将表B的记录数显示到相应表A的记录下,查询怎么写,变量如何定义。我查了一天,网上都是表单或URL的变量实例。
谢谢。我刚使用Dreamweaver写ASP,请将答案尽量详尽。
谢谢!
我的代码: Proposalid 就是上面的A.ID B.ID
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<!--#include file="Connections/conn.asp" -->
<%
Dim allproposal
Dim allproposal_cmd
Dim allproposal_numRows
Set allproposal_cmd = Server.CreateObject (")
allproposal_cmd.ActiveConnection = MM_conn_STRING
allproposal_ = "SELECT * FROM proposal ORDER BY createdby DESC"
allproposal_cmd.Prepared = true
Set allproposal = allproposal_cmd.Execute
allproposal_numRows = 0
Dim Repeat1__numRows
Dim Repeat1__index
Repeat1__numRows = -1
Repeat1__index = 0
allproposal_numRows = allproposal_numRows + Repeat1__numRows
%>
<%
Dim Repeat2__numRows
Dim Repeat2__index
Repeat2__numRows = -1
Repeat2__index = 0
Recordset1_numRows = Recordset1_numRows + Repeat2__numRows
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.
<html xmlns="http://www.
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style type="text/css">
body,td,th {
font-family: Arial, Helvetica, sans-serif;
font-size: 9px;
}
</style>
</head>
<body>
<%
While ((Repeat1__numRows <> 0) AND (NOT allproposal.EOF))
%>
<br />
<table width="600" border="1">
<tr bgcolor="#FFFFCC">
<th scope="col"><u>ID</u></th>
<th scope="col"><u>Date</u></th>
<th scope="col"><u>Proponent</u></th>
<th scope="col"><u>Status</u></th>
<th scope="col"><u>Suggestion</u></th>
<th scope="col"><u>Exp_result</u></th>
<th scope="col"><u></u></th>
<th scope="col"><u></u></th>
<th scope="col"><u></u></th>
<th scope="col"><u></u></th>
</tr>
<tr bgcolor="#FFFFCC">
<td><%=(allproposal.Fields.Item("ProposalID").Value)%></td>
<td><%=(allproposal.Fields.Item("Date1").Value)%></td>
<td><%=(allproposal.Fields.Item("Proponent").Value)%></td>
<td><%=(allproposal.Fields.Item("Status").Value)%></td>
<td><%=(allproposal.Fields.Item("Suggestion").Value)%></td>
<td><%=(allproposal.Fields.Item("exp_result").Value)%></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr bgcolor="#FFFFCC">
<td><u>Teamsolution</u></td>
<td><u>Remark</u></td>
<td><u>finishdate</u></td>
<td><u>Createby</u></td>
<td><u>Createdate</u></td>
<td><u></u></td>
<td><u></u></td>
<td><u></u></td>
<td><u></u></td>
<td><u></u></td>
</tr>
<tr bgcolor="#FFFFCC">
<td><%=(allproposal.Fields.Item("Teamsolution").Value)%></td>
<td><%=(allproposal.Fields.Item("Remark").Value)%></td>
<td><%=(allproposal.Fields.Item("Finishdate").Value)%></td>
<td><%=(allproposal.Fields.Item("createdby").Value)%></td>
<td><%=(allproposal.Fields.Item("createddate").Value)%></td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr bgcolor="#FFFFCC">
<td><u>Mgrsign</u></td>
<td><u>mgrsigndate</u></td>
<td><u>Mgr_result</u></td>
<td><u>Mgrresultdate</u></td>
<td><u>Rejextreason</u></td>
<td><u>Rep_unit</u></td>
<td><u>Action</u></td>
<td><u>Deadline</u></td>
<td><u></u></td>
<td><u></u></td>
</tr>
<tr bgcolor="#FFFFCC">
<td><%=(allproposal.Fields.Item("mgrsign").Value)%></td>
<td><%=(allproposal.Fields.Item("mgrsigndate").Value)%></td>
<td><%=(allproposal.Fields.Item("mgr_result").Value)%></td>
<td><%=(allproposal.Fields.Item("mgrresultdate").Value)%></td>
<td><%=(allproposal.Fields.Item("rejectreason").Value)%></td>
<td><%=(allproposal.Fields.Item("rep_unit").Value)%></td>
<td><%=(allproposal.Fields.Item("Action").Value)%></td>
<td><%=(allproposal.Fields.Item("deadline").Value)%></td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<br />
<br />
<%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
allproposal.MoveNext()
Wend
%>
</body>
</html>
<%
allproposal.Close()
Set allproposal = Nothing
%>