我在jsp中用到了java处理sql语句,但在运行时MyEclipse时报出错误,找不到问题出在哪里,求各位的帮助!
报出的错误:java.sql.SQLException:YouhaveanerrorinyourSQLsyntax;checkthemanualthatcorrespon...
报出的错误:
java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select tid from xuanke where username= '1001' limit 0,3' at line 1 Query: select teacher.tphone from teacher where tid = select tid from xuanke where username= '1001' limit 0,3 Parameters: []
具体的sql语句是一个子查询:
String sql = "select teacher.tphone"
+ " from teacher"
+ " where tid = select tid from xuanke where username= '1001' "; 展开
java.sql.SQLException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'select tid from xuanke where username= '1001' limit 0,3' at line 1 Query: select teacher.tphone from teacher where tid = select tid from xuanke where username= '1001' limit 0,3 Parameters: []
具体的sql语句是一个子查询:
String sql = "select teacher.tphone"
+ " from teacher"
+ " where tid = select tid from xuanke where username= '1001' "; 展开
展开全部
" where tid in ( select tid from xuanke where username= '1001' ");
嵌套子查询 要带括号 再把=号 改成in
嵌套子查询 要带括号 再把=号 改成in
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
String sql = "select teacher.tphone"
+ " from teacher"
+ " where tid = (select tid from xuanke where username= '1001' )";
+ " from teacher"
+ " where tid = (select tid from xuanke where username= '1001' )";
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询