Java再用@Select拼接sql语句时候,

#{参数名}:是加引号的

${参数名}:是不加引号的

 

例如:

userIds为List或者数组,值为1,2,3,4,5

1.@Select("select * from users where userId in  (#{userIds})")

翻译为sql语句之后为:select * from users where userId in ('1,2,3,4,5')

2.@Select("select * from users where userId in  (${userIds})")

翻译为sql语句之后为:select * from users where userId in (1,2,3,4,5)

相关文章:

  • 2021-11-20
  • 2022-01-07
  • 2021-10-02
猜你喜欢
  • 2022-12-23
  • 2021-07-17
  • 2021-06-10
  • 2022-12-23
  • 2022-12-23
  • 2021-11-27
  • 2021-06-23
相关资源
相似解决方案