jsp中查询语句的问题

来源:百度知道 编辑:UC知道 时间:2024/06/28 04:38:58
报错在50 说我有语法错误: 百思不得其解 =口=
check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

--------------代码如下------

String sql = "select * from book where";
String where = "";

for(int i=0;i <= 3 && !keyword[i].equals("");i++){
if(i != 0){
where+=andor[i-1];

}
where+=" "+condition[i]+" like '%"+keyword[i]+"%'";
}

sql+=where;

....链接数据库 中间略 已经检测 无误....

49 Statement stmt = conn.createStatement();
50 ResultSet rs = stmt.executeQuery(sql);
keyword[i]是存放查询属性的字符串数组,andor[i]是存放逻辑连接词 and or的字符串数组

以下是我接受输入的语句:然后存放到searchBookAdvancedStep2.jsp的那几个字符串数组里

<form method="post" action="searchBookAdvancedStep2.jsp">
<select name = "condition1">
<option value

报错的信息是sql语句出错
但我看了一遍,语法上没有错阿
是不是你存放得condition或者keyword又或者andor本身有存放错误数据呢??

楼主加我的QQ...点击韦涵涵...我一定帮你解决....

祝楼主早日成功!