SQL DECODED: Newid is just an internal MS SQL Server variable for the row; note that this code will work in v7, as well as 2000.
"select top 10" means what it reads: Get only the first ten results of the query. This is a a useful clause for returning a query when you only want the top X results (for example, some weird join that will have massive dupes, but you only want the one record for the code's use blah blah). You can replace "10" with any positive integer >Not too sure to be honest... > >I found it from a site after I was using a stored procedure and a loop (not >the best code in the world) > >But basically (AFAIK) it says, get me the top 10 items from table foo and >order these by a random number. Thus if you call it again then the number >you are ordering is different, hence the random rows returned. > > >HTH > > > >-----Original Message----- >From: admin [mailto:[EMAIL PROTECTED] >Sent: Wednesday, August 27, 2003 10:02 >To: CF-Talk >Subject: Re: ot - random sql select > > >Thanks mike I'll give that a try - but out of interest what does that code >really mean ? - ok - so I'm an idiot in sql ! > >Cheers > >Richard > >----- Original Message ----- >From: "Mike Townend" <[EMAIL PROTECTED]> >To: "CF-Talk" <[EMAIL PROTECTED]> >Sent: Wednesday, August 27, 2003 1:28 AM >Subject: RE: ot - random sql select > > >> If you are using SQLServer 2K (not sure if it works in 7) you could >> use >> >> SELECT TOP 10 * >> FROM Foo >> ORDER BY NewID() >> >> >> HTH >> >> >> >> -----Original Message----- >> From: admin [mailto:[EMAIL PROTECTED] >> Sent: Wednesday, August 27, 2003 07:11 >> To: CF-Talk >> Subject: ot - random sql select >> >> >> is there an easy way to select say 10 records at random from an sql >> table >? >> >> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Archives: http://www.houseoffusion.com/lists.cfm?link=t:4 Subscription: http://www.houseoffusion.com/lists.cfm?link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Your ad could be here. Monies from ads go to support these lists and provide more resources for the community. http://www.fusionauthority.com/ads.cfm

