MyBatis Oracle与MySQL分页

Oracle、MySQL分页实例

  • SQL执行代码
ORACLE:
SELECT * FROM (
	SELECT ROWNUM AS NUMROW, Z.* from (
		select * from CHANNEL T where 1=1 and T.ID = 1 ORDER BY T.ID desc 
	) Z  where rownum<=10
) WHERE NUMROW >= 1 


MySQL:获取(0 ,10],10表示向后获取10条数据。
select * from fm_sell T 
where 1=1 and T.SERIAL_NUM = '20141124' ORDER BY T.ID desc LIMIT 0, 10

 

  • Mybatis中分页应用与优化
Oracle:

	
		1=1
		
			AND T.ID = #{id,jdbcType=BIGINT}
		
		...
	



	ORDER BY T.ID desc 



	SELECT * FROM (SELECT ROWNUM AS NUMROW, Z.* from (



	= #{pageFristItem} ]]>




 

MySQL:

	
	
	...



	T.ID, T.SERIAL_NUM, T.STOCK_ID, T.GMT_CREATE, T.GMT_MODIFY



	
		1=1
		
			AND T.SERIAL_NUM = #{serialNum,jdbcType=VARCHAR}
		
		...
	




	LIMIT #{pageIndex}, #{pageSize}



	ORDER BY T.ID desc 






你可能感兴趣的:(MyBatis,Oracle,MySQL)