SQL: Select Top X

February 12th, 2008

I do a lot of work with identity, and it’s very common to be connecting to an Oracle, Microsoft SQL, and sometimes even MySql databases . . . all in the same project.

What I do with SQL in these instances is so basic it really doesn’t matter. Usually it’s just a glorified CSV file. However there is one SQL statement I use on a regular basis that isn’t standard between any of the three SQL engines. (thanks to Thea Burgers Blog for putting this information all in one place):

SQL Server:

SELECT TOP 10 * FROM table

ORACLE:

SELECT * FROM table WHERE ROWNUM <=10

MYSQL:

SELECT * FROM table LIMIT 10

Time for a little standardization?

One Response to “SQL: Select Top X”

  1. Elden Warner Says:

    I think I understand a few words on this page, but, then again, I am not entirely sure.

Leave a Reply