Whatever her query is now, she (I assume it's a she) needs to add the TOP keyword to get only x records, then the order by NEWID() clause to get random records. And no it won't just show the most recently added products, because you are sorting by a value that is assigned at runtime and random each time its run.
Taco Fleur Tell me and I will forget Show me and I will remember Teach me and I will learn > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf > Of Peter Tilbrook > Sent: Sunday, 11 July 2004 11:31 AM > To: CFAussie Mailing List > Subject: [cfaussie] RE: Outputting a random result from a query > > > But won't that only show the most recently added product to > the table? Also a cross database compatible is maxrows="1" in > the cfquery tag. > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf > Of Taco Fleur > Sent: Sunday, 11 July 2004 11:24 AM > To: CFAussie Mailing List > Subject: [cfaussie] RE: Outputting a random result from a query > > IF on MS SQL add TOP 1 to your select > And add ORDER BY NEWID() > > Example > > SELECT TOP 1 * > FROM product > ORDER BY NEWID() > > Taco Fleur > > Tell me and I will forget > Show me and I will remember > Teach me and I will learn > > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of Seona > > Bellamy > > Sent: Sunday, 11 July 2004 11:21 AM > > To: CFAussie Mailing List > > Subject: [cfaussie] Outputting a random result from a query > > > > > > Hi guys, > > > > Well, I fixed my other problems after a bit of fiddling (the coding > > ones, anyway...). This new one is just a logic thing which > I'm having > > trouble figuring out. > > > > I have a query that looks through the Product table in the database > > and finds all the products that are listed as "on special". What I > > want to do is select a random item from the recordset > returned by this > > query and output it into the sidebar of the site so that every time > > you visit the page you see a random product that is on special. > > > > How do I go about doing this? Do I have to apply some randomisation > > logic to the query, or is it something done post-query? And what is > > the logic I need to apply? I've gone around in circles on > this one and > > I just can't work it out. > > > > Thanks, > > > > Seona. > > > > --- > > You are currently subscribed to cfaussie as: > > [EMAIL PROTECTED] To unsubscribe send a blank email to > > [EMAIL PROTECTED] > > Aussie Macromedia Developers: http://lists.daemon.com.au/ > > > > > --- > You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To > unsubscribe send a blank email to > [EMAIL PROTECTED] > Aussie Macromedia Developers: http://lists.daemon.com.au/ > > > > > > --- > You are currently subscribed to cfaussie as: [EMAIL PROTECTED] > To unsubscribe send a blank email to > [EMAIL PROTECTED] > Aussie Macromedia Developers: http://lists.daemon.com.au/ > --- You are currently subscribed to cfaussie as: [EMAIL PROTECTED] To unsubscribe send a blank email to [EMAIL PROTECTED] Aussie Macromedia Developers: http://lists.daemon.com.au/
