sql在不同資料庫查詢前幾條資料
關鍵字: sql 前幾條結果
sql在不同資料庫查詢前幾條資料
1. oracle
select * from table1 where rownum<=n
select * from stu_info where rownum<=10 (查詢學生資訊表的前10條資料)
hql: from table1 t order by t.createtime desc where rownum<=n
hql:from stu_info s order by s.creattime desc where rownum<=10
2. informix
select first n * from table1
3. db2
select * row_number() over(order by col1 desc) as rownum where rownum<=n
或者 select column from table fetch first n rows only
4. sql server
select top n * from table1select top 10 * from stu_info (前10條資料)
5. sybase
set rowcount n
go select * from table1
6. mysql (mysql)
select * from table1 limit nselect * fron stu_info limit 10
hibernate查詢記錄的前10條記錄
就像mysql的sql語句的"select * from table limit 10" hql 不支援limit
query.setfirstresult(0);//從第0條開始取
query.setmaxresults(10);//取十條記錄
各種資料庫查詢前幾條資料
1.oracle資料庫 select from tablename where rownum n 2.infomix資料庫 select first n from tablename 3.db2資料庫 select from select row number over as rownum from...
資料庫 讀取前幾條資料
1.oracle資料庫 select from tablename where rownum n 2.infomix資料庫 select first n from tablename 3.db2資料庫 select from select row number over as rownum from...
SQL查詢前幾條資料的方法
sql在不同資料庫查詢前幾條資料 1.oracle select from table1 where rownum n hql from table1 t order by t.createtime desc where rownum n 2.informix select first n from...