Heim > Fragen und Antworten > Hauptteil
有个模糊查询
String sql = "select * from emp e where e.name like '?|%'";
Map<String, Object> map = jdbcTemplate.queryForMap(sql, new Object[] { empCode});
上面的写法不对,请问如何做转义?
高洛峰2017-04-18 10:29:15
转义后如下:
String sql = "select * from emp e where e.name like '?|/%' ESCAPE '/'";
网上有关模糊查询中特殊字符(下划线_,百分号%,方括号[],尖号^)的处理,可以搜索详细了解
伊谢尔伦2017-04-18 10:29:15
String sql = "select * from emp e where e.name like ? ";
Map<String, Object> map = jdbcTemplate.queryForMap(sql, new Object[] { empCode});