从多个表查询数据库:
如何从多个表查询数据,以下是问题,各位大虾是怎么从多个表查询数据的?
SQL语句:
rs=sql.executeQuery( "select distinct goods.goodsname,goods.price,dingdan.amount
from goods,dingdan
where goods.goodsID=dingdan.goodsID and dingdan.email= ' "+email+ " ' ");
下面是错误:
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 13 in the jsp file: /11/l4.jsp
Generated servlet error:
D:\jakarta-tomcat-5.0.28\work\Catalina\localhost\_\org\apache\jsp\_11\l4_jsp.java:72: unclosed string literal
rs=sql.executeQuery( "select distinct goods.goodsname,goods.price,dingdan.amount
^
An error occurred at line: 13 in the jsp file: /11/l4.jsp
Generated servlet error:
D:\jakarta-tomcat-5.0.28\work\Catalina\localhost\_\org\apache\jsp\_11\l4_jsp.java:74: unclosed character literal
where goods.goodsID=dingdan.goodsID and dingdan.email= ' "+email+ " ' ");
^
An error occurred at line: 13 in the jsp file: /11/l4.jsp
Generated servlet error:
D:\jakarta-tomcat-5.0.28\work\Catalina\localhost\_\org\apache\jsp\_11\l4_jsp.java:74: ') ' expected
where goods.goodsID=dingdan.goodsID and dingdan.email= ' "+email+ " ' ");
^
3 errors
[解决办法]
你先把你的sql语句放到查询分析器里面去看看又没有语法错误,然后在放到jsp中.多表查询我一般都用连接,像你这个你可以用一下内联(inner join).
[解决办法]
是jsp程序的问题。
你将sql 输出看看是什么,仔细检查页面程序。设置断点。
[解决办法]
输出是检验这个sql语句正确的最好方法
[解决办法]
String str = "select distinct goods.goodsname,goods.price,dingdan.amount "+
"from goods,dingdan "+
"where goods.goodsID=dingdan.goodsID and dingdan.email= ' "+email+ " ' ";
我的异常网推荐解决方案:The server encountered an internal error () that prevented it from fulfilling this request.,http://www.myexception.cn/java-web/317.html
我的异常网推荐解决方案:org.apache.jasper.JasperException: Unable to compile class,http://www.myexception.cn/j2ee/2308.html