Anorm LIKE clause with String Interpolation

后端 未结 1 1915
孤城傲影
孤城傲影 2020-12-11 19:19

Is it possible to use LIKE clause with String Interpolation in Anorm?

// e.g. this doesn\'t work
SQL\"SELECT * FROM users WHERE last_name LIKE $lastName%\".a         


        
相关标签:
1条回答
  • 2020-12-11 19:47

    If expected WHERE clause is something like WHERE last_name LIKE '%pattern%' you will have to prepare string before passing it as argument.

    SQL"""SELECT * FROM users WHERE last_name LIKE ${"%"+lastName+"%"}""".
      as(userParser.*)
    
    0 讨论(0)
提交回复
热议问题