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

your MySQL server version for the right syntax to use near 'COMMAND='??''

照着视频拔下来的代码,怎么就提示这里错了呢

StringBuilder sql = new StringBuilder("select ID,COMMAND,DESCRIPTION,CONTENT from message where 1=1");

List<String> paramList = new ArrayList<String>();

if(command!=null && !"".equals(command.trim())){

sql.append("and `COMMAND`=?");

paramList.add(command);

}

if(description!=null && !"".equals(description.trim())){

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

paramList.add(description);

}

PreparedStatement statement = conn.prepareStatement(sql.toString());


提问者:盗王之王 2016-01-14 16:58

个回答

  • c根树
    2016-01-18 17:52:36

    buffer.append(" and description like '%'||?||'%'");用这个形式。

  • 盗王之王
    2016-01-15 08:59:26

    我自己知道了,少了个空格sql.append(" and COMMAND=?");