在正常的java类里可以这样 比如一段sql语句 “select * from (xx”**+**fileIds+ “ ) as files” 但是在xml文件里面 这个+的地方怎么处理呢?
在xml中使用sql字符串拼接和你的数据库有关,如果你是orcale: 关键符号 ||
select * from student where name like '%' || #{name} || '%'
实现了%和你的参数字符串进行拼接,上面就是一个模糊查询的小例子,一般用到字符串拼接的sql一般也只有这个
如果你使用数据库是mysql,关键符号 concat(,,)
select * from student where name like concat('%' , #{name} , '%')
实现了%和你的参数字符串进行拼接
如果是mybatis的XML,在写sql的时候使用sql的字符串连接函数即可,像concat
.