SELECT TOP 1 *
FROM Quotes
ORDER BY NEWID()

-- 
Taco Fleur
Senior Web Systems Engineer
http://www.webassociates.com


-----Original Message-----
From: Duncan I Loxton [mailto:[EMAIL PROTECTED] 
Sent: Thursday, 3 February 2005 2:13 PM
To: CF-Talk
Subject: Random row from SQL table

Hi,

I need to get one row and one row only from a sql table - cheesy quotes for
our corporate intranet.....

The table is like this:
CREATE TABLE dbo.Quotes (
        quo_id int NOT NULL IDENTITY (1, 1),
        quo_text text,
        quo_author varchar(100),
        quo_wwwSite int
) 

Now wwwSite is the id of the website we are currently on, as this table is
shared between sites and quotes are different depending on where you are.

I need to get one random(ish) row from the quotes table from the subset of
wwwSite = 3.  Is it possible to do in one query? or will I have to run 2?

I am using CF4.5

Thanks!

--
Duncan I Loxton



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble 
Ticket application

http://www.houseoffusion.com/banners/view.cfm?bannerid=48

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:192849
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to