MySQL Forums
Forum List  »  Oracle

Re: rownum-Problem
Posted by: Anders Karlsson
Date: December 22, 2004 01:59PM

This is that, a ROWNUM in Oracle is the sequential ID of the row as it is retrieved. So you cannot do:
SELECT * FROM sometable WHERE rownum = 17;
as with this condition, you will never get to row 17, as to find a row 17, you first have to find rows 1 to 16, which you have already stated that you don't want. The same reasoning goes for 57 also :-)
At least this is how rownum worked in the good old days. And nothiing wrong with that, as long as you know how it works.
To do what you want to do in MySQL is actually much MUCH easier. Just do this:
SELECT * FROM mytable ORDER BY rand() LIMIT 200;
That's it...

/Karlsson

Options: ReplyQuote


Subject
Views
Written By
Posted
18294
August 06, 2004 12:28AM
28607
September 26, 2004 09:04AM
12194
October 09, 2004 03:02PM
22871
October 10, 2004 12:56PM
12704
December 22, 2004 07:05AM
Re: rownum-Problem
13710
December 22, 2004 01:59PM
9873
April 13, 2005 01:25PM
13193
April 14, 2005 12:08AM
7289
April 26, 2005 02:12AM
7850
April 20, 2005 04:37PM
10266
April 23, 2005 09:48AM
5842
August 26, 2008 03:47AM
6058
April 26, 2005 02:16AM
5822
October 18, 2005 02:57PM
5804
November 16, 2005 04:58PM
19353
August 08, 2006 07:45AM
5504
December 14, 2008 10:01PM
5689
February 05, 2009 04:49PM
4883
December 27, 2008 03:27AM
4980
December 27, 2008 04:19AM
6715
February 08, 2007 02:20AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.