Click to See Complete Forum and Search --> : Random sequel server entry


cs3mw
02-17-2009, 04:04 PM
Hi, I am trying to generate a radom entry from a sequel server database.

I have four fields called entryID, name, department and quizID. What I would like to do is display a random entryID from the table. I have the following which is simply displaying the first entry.


SELECT TOP 1 entryID, [name] FROM PuzzleSubmit WHERE quizID='2' ORDER BY RAND()


Has anyone any ideas? Unfortunately I am used to working in a mysql environment so I do apoligise for asking such a simple question and this piece of work has to be demoed tomorrow otherwise I would have done more research.

Regards

Mike

cs3mw
02-18-2009, 01:49 PM
Hi Ive worked it out here I am just selecting the top entry when the entrys are ordered in a random order

SELECT TOP 1 name, department FROM PuzzleSubmit WHERE quizID='2' ORDER BY NEWID()