asp 显示数据库内容时如何将两个表连在一起? 10

如:有两个表:choose_course,student其中choose_course表中有teachername,studentid字段,表student中也有stud... 如:有两个表:choose_course,student
其中choose_course表中有teachername ,studentid 字段,表student中也有studentid等字段
我想通过条件choose_course表中teachername='"+Session("teachername")+"' 并且studentid=(student表中studentid)
称想显示student表中符合上述条件的信息!请问具体要怎样写sql语句?

如查我想写成下面这样要怎样改呢?
<%
set dbconnection=Server.CREATEOBJECT("ADODB.CONNECTION")
DBPath = Server.MapPath("../data.mdb")
dbconnection.Open "driver={Microsoft Access Driver (*.mdb)};dbq=" & DBPath
'SQL="select * from student where studentid="+Session("studentid")+"
SQL="select * from choose_course,student where teachername='"+Session("teachername")+"' and

choose_course.studentid=student.studentid"
set mystu=dbconnection.execute(SQL)
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>myclass</title>
<style type="text/css">
<!--
body {
margin-top: 0px;
}
body,td,th {
font-size: 14px;
}
-->
</style></head>

<body>
<table width="618" border="0" align="center" bgcolor="#ffffcc">
<tr>
<td><font color="blue"><b>学号<b></font></td><td><font color="blue"><b>姓名<b></font></td><td><font

color="blue"><b>性别<b></font><td><td><font color="blue"><b><font color="blue"><b>学院<b></font></td><td><font

color="blue"><b>电话<b></font></td><td><font color="blue"><b>email<b></font></td><td><font color="blue"><b>生日

<b></font></td> </td>
</tr>
<% DO WHILE NOT myifo.EOF %>
<TR>
<td><% =mystu("studentid") %></td><td><% =mystu("studentname") %></td><td><% =mystu("sex") %><td><td><% =mystu

("collage") %></td><td><% =mystu("phonenumber") %></td><td><% =mystu("email") %></td><td><% =mystu("birthday") %

></td> </td>
</tr>
<% myifo.movenext
loop
%>
</table>
</body>
二楼的好像不行,还有我这里写错了点,<% DO WHILE NOT myifo.EOF %> 这里和下面的我已发现改正过来试了,再按二楼给的答案写上去还是不行啊!谁可以帮我解答.
展开
 我来答
帮助_li
2006-04-18 · TA获得超过2140个赞
知道大有可为答主
回答量:1288
采纳率:65%
帮助的人:669万
展开全部
"select * from choose_course,student where choose_course.studentid and student.studentid and teachername="+Session("teachername");
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式