If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > Select 5 Random Records

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-25-04, 19:31
simsjr simsjr is offline
Registered User
 
Join Date: Aug 2004
Posts: 19
Select 5 Random Records

Anyone know how I can select only 5 random records from an Informix table?
Reply With Quote
  #2 (permalink)  
Old 10-26-04, 11:48
artemka artemka is offline
Registered User
 
Join Date: May 2004
Location: New York
Posts: 248
Unless you give the order by, there is no guarantee on how you will get the records from the table.

5 records you can get by executing the following

select first 5 * from table_name

Cheers
Reply With Quote
  #3 (permalink)  
Old 10-27-04, 10:12
fprose fprose is offline
Registered User
 
Join Date: Apr 2003
Location: Phoenix, AZ
Posts: 177
The process that I have used in the past is based upon selecting random ROWID's with the range min(ROWID) and max(ROWID).

I used a random number routine to generate a random number between the min and the max and then SELECT the row based upon ROWID. HOWEVER, just because you generate a number does not mean that that ROWID exists. So the SELECT statement was something like "SELECT FIRST 1 ... WHERE ROWID >= myrandonmumber"
__________________
Fred Prose
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On