SELECT * FROM ( SELECT (@rownum := @rownum + 1) AS rownum,c.* FROM (SELECT @rownum := 0) r, ( select * from sys_user_work where creator = #{params.userId} ) c <!--ORDER BY aa.create_date desc--> ) aa <where> <if test="params.lastRowNum!=null"> rownum > ${params.lastRowNum} </if> </where> <if test="params.pageSize!=null"> LIMIT ${params.pageSize} </if> </select>