轉 查詢前幾條記錄SQL在不同資料庫中的用法

2021-04-13 06:18:05 字數 720 閱讀 5668

查詢前幾條記錄sql在不同資料庫中的用法;

1. oracle

select * from table1 where rownum<=n

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 table1

5. sybase

set rowcount n

goselect * from table1

6. mysql

select * from table1 limit n

7. foxpro

select * top n from table order by column

選擇從10到15的記錄

select * from (select * from (select * from  table_name  order by id asc) where rownum<16  order by id desc) where rownum<11 order by id asc

查詢前幾條記錄SQL在不同資料庫中的用法

查詢前幾條記錄sql在不同資料庫中的用法 1.oracle select from table1 whererownum n 2.informix selectfirstn from table1 3.db2 select row number over order by col1 desc as ...

查詢前幾條記錄SQL在不同資料庫中的用法

查詢前幾條記錄sql在不同資料庫中的用法 1.oracle select from table1 where rownum n 2.informix select first n from table1 3.db2 select row number over order by col1 desc ...

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...