该错误出现的原因之一可能是使用sql分页部分的问题。
我的项目部分代码
<!--获取所有用户 -->
<select id="getAllUser" parameterType="String" resultType="user">
select *
from [addrbook].[dbo].[user]
<where>
<if test="truename != null and truename !='' ">
truename like concat("%",#{truename},"%")
</if>
</where>
<!-- 执行分页查询 -->
<if test="start != null and rows != null">
limit #{start},#{rows}
</if>
</select>
在我的项目中原本是使用mysql数据库,通过mysql中的limit来实现数据库语句分页,现如今我换成了sqlserver,这就导致了这个问题的产生。在sqlserver中实现sql语句分页是不支持limit的,需要通过top或者row_number()来实现。
本文介绍了一种在从MySQL切换到SQLServer时遇到的分页查询问题。由于SQLServer不支持MySQL中的LIMIT语法,因此需要采用TOP或ROW_NUMBER()等方法进行替代。文章详细讨论了如何调整MyBatis映射文件中的SQL语句以适应新的数据库。
238





