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

后端 未结 9 947
面向向阳花
面向向阳花 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:47

    || operator worked for me in IBatis but not in Mybatis.

    In MyBatis i had to use + operator.

    SELECT *
    FROM Employee
    WHERE
    name like '%' + #{searchName,jdbcType=NVARCHAR} + '%'
    

提交回复
热议问题