Cool
Cool
Published on 2021-05-19 / 25 Visits
0
0

MySQL JdbcTemplate 模糊查询

使用JdbcTemplate 模糊查询SQL拼写时应该使用 CONCAT()函数来拼接%  模糊查询

错误的SQL语句写法

SELECT area_id FROM sys_area WHERE area_code LIKE ?%

正确的SQL语句写法

SELECT area_id FROM sys_area WHERE area_code LIKE CONCAT(?,'%')

{card-describe title="CONCAT()函数的用法"} 功能:将多个字符串连接成一个字符串。

语法:concat(str1, str2,...) {/card-describe}


返回结果为连接参数产生的字符串,如果有任何一个参数为null,则返回值为null。


Comment