Have following String built SQL query:
StringBuilder querySelect = new StringBuilder("select * from messages ");
StringBuilder queryWhere = new StringBuilder("where msg_id=?");
if (fileRSVO.getFileName()!= null){
queryWhere.append("and descr LIKE %?% ");
}
querySelect.append(queryWhere);
List<Map<String, Object>> list = getJdbcTemplate().queryForList(querySelect.toString(), params.toArray());
...
The problem is in this part:
queryWhere.append("and descr LIKE %?% ")
LIKE
doesn't work.
Checked in debug - it's added to all query.
Should it be single quoted or some other trick?
thanks.
EDITED
tried single quotes:queryWhere.append("and descr LIKE '%?%' ")
doesn't work
here is debug string:
select * from messages where msg_id=? and descr LIKE '%?%'