Minying's Blog

Just another WordPress.com weblog

資料庫中查前幾筆資料語法

Posted by minying 於 5 五月, 2009

各資料庫中,查詢前幾筆資料語法有所差異。

DB2:

Select * From Table1 Order By Column1 Fetch First 10 Row Only

SQL Server:

Select Top 10 * From Table1 Order By Column1

MySQL:

Select * From Table1 Limit 10

Select * From Table Limit 10,5     查詢第11筆開始後5筆

Select * From Table Limit 10,-1     查詢第11筆開始至最後一筆

發表留言