问答详情
源自:2-6 列表查询

带有like的拼接出错

com.mysql.jdbc.exceptions.jdbc4.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 'description like '%''erer''%'' at line 1 怎么拼接的时候会出现这个错呢

提问者:boooooomb 2016-07-26 11:27

个回答

  • 齐楚秦燕赵魏韩
    2016-07-26 13:43:58
    已采纳

    SELECT ID,COMMAND,DESCRIPTION,CONTENT FROM message WHERE 1=1 AND DESCRIPTION LIKE '%' ? '%';

    sql.append(" and DESCRIPTION like '%' ? '%'");

    正确拼接

  • qq_深拥海洋_0
    2016-09-11 19:08:31

    我也是这个问题 你怎么解决的