RE: Retrieve a random record from a database

2004-07-21 Thread James Smith
Is there a MySQL equivalent to this newID() functionality? -- Jay -Original Message- From: Charlie Griefer [mailto:[EMAIL PROTECTED] Sent: 20 July 2004 22:42 To: CF-Talk Subject: Re: Retrieve a random record from a database as a rule, you should try not to pull more records

RE: Retrieve a random record from a database

2004-07-21 Thread Tim Blair
Is there a MySQL equivalent to this newID() functionality? With MySQL you can pull out one random row by using a combination of ORDER BY RAND() and LIMIT, e.g.: SELECT * FROM myTable ORDER BY RAND() LIMIT 1 Tim. -- --- Badpen Tech - CF and

Retrieve a random record from a database

2004-07-20 Thread Dustin Snell [Network Automation, Inc]
We have a database with a bunch of customer testimonials in it. Records can be added to it at anytime. Some are marked public and some or not. Does anyone know how I could pull a single record randomly from the database using MSSQL2000 and CF6.1 for display on the website - but only out of the

Re: Retrieve a random record from a database

2004-07-20 Thread Jeff Langevin
You could query for all public records and then use randRange(1,myquery.recordcount).That'll give you a random row.Then use the primary key to do whatever you need form there.HTH. --Jeff Dustin Snell [Network Automation, Inc] wrote: We have a database with a bunch of customer testimonials in

Re: Retrieve a random record from a database

2004-07-20 Thread Charlie Griefer
SELECT TOP 1 field1, field2, ... FROM table WHERE public = 1 ORDER BY newID() - Original Message - From: Dustin Snell [Network Automation, Inc] [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Tuesday, July 20, 2004 2:21 PM Subject: Retrieve a random record from a database

Re: Retrieve a random record from a database

2004-07-20 Thread JediHomer
You could do something like SELECT TOP 1 * FROM Testiments WHERE Public = 1 ORDER BY NewID() HTH - Original Message - From: Dustin Snell [Network Automation, Inc] [EMAIL PROTECTED] Date: Tue, 20 Jul 2004 14:21:44 -0700 Subject: Retrieve a random record from a database To: CF-Talk [EMAIL

Re: Retrieve a random record from a database

2004-07-20 Thread Charlie Griefer
your app's portability suffers a bit) - Original Message - From: Jeff Langevin [EMAIL PROTECTED] To: CF-Talk [EMAIL PROTECTED] Sent: Tuesday, July 20, 2004 2:34 PM Subject: Re: Retrieve a random record from a database You could query for all public records and then use randRange(1

Re: Retrieve a random record from a database

2004-07-20 Thread Jeff Langevin
] Sent: Tuesday, July 20, 2004 2:21 PM Subject: Retrieve a random record from a database We have a database with a bunch of customer testimonials in it. Records can be added to it at anytime. Some are marked public and some or not. Does anyone know how I could pull a single record randomly