(How) can I use “LIKE” in SQL queries with MyBatis safely and DB-agnostic?

后端 未结 9 1083
面向向阳花
面向向阳花 2021-02-04 03:33

In MyBatis, you mark the places where parameters should be inserted into your SQL like so:

SELECT * FROM Person WHERE id = #{id}

9条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-04 03:56

    In mybatis annotation @Select

    for SQL server "... LIKE '%' + #{param} + '%' ..."

    for ORACLE "... LIKE '%' || #{param} || '%' ..."

    ref : https://mybatis.org/mybatis-3/java-api.html

提交回复
热议问题