Jump to content

Limit in Oracle

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1
Apaul

Apaul

    Newbie

  • Members
  • Pip
  • 1 posts
Hi,

i have a Mysql query which returns me a set of records say 1 to 10 using limit.
But the same query doesn't work with Oracle. In oracle limit function is not there instead i can use rownum, but rownum is not supported by MySql .

I am looking for a common query which works with both MySql as well as with Oracle. Is there any way to do so ?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
Unfortunately, no.

One of the frustrations I'm dealing with in one program I have is that Oracle, Firebird, and SQL Server use three completely different limit function syntaxes. To make matters worse, there isn't a good way on SQL Server to get records 101-200! There's a hack, but it doesn't work very well. Oracle is a little bit hackish as well.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Guest_Jordan_*

Guest_Jordan_*
  • Guests
I've ran into that problem before. Here is how to do it in MySQL, Oracle and MsSQL:

// mysql
select col from table limit 10;

// Oracle
select col from table where rownum<=10;

// Microsoft SQL
select top 10 col from table;