Java在使⽤@Select遇到的问题:拼接字符串将数组拼为了字符
串
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})")
java数组字符串转数组翻译为sql语句之后为:select * from users where userId in (1,2,3,4,5)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论