> 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 w
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
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
>
> > We have a database with a bunch of customer testim
r specific...so 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 d
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: C
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 from the database
>
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 testimoni
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
reco
8 matches
Mail list logo