我写的部分代码
sb.append("select * from tianmg_goddess where 1=1");
//sb.append(" where user_name like ? and mobile like ?");
if(params!=null &¶ms.size()>0){
for (int i = 0; i < params.size(); i++) {
Map map=params.get(i);
sb.append(" and "+map.get("name")+" "+map.get("rela")+" "+map.get("value")+" ");
}
显示结果
select * from tianmg_goddess where 1=1 and user_name = '小美' and mobile = '18451922609'
Exception in thread "main" com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: 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 '? and mobile = '18451922609'?' at line 1