Random Select Query

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
11/19/2008 1:32:25 PM
Gravatar
Total Posts 58

Random Select Query

How would you go about doing a random select query? This is what I did, so far it seems to work. I don’t know if it will perform that well though. It seems to run fine in local load testing.

SELECT TOP 1
NEWID() AS [RANDOM],
Guid,
Author,
Quotation
FROM
dbo.mp_Quotes
ORDER BY
[RANDOM] ASC

http://aaronstanleyking.com/random-quotes-0001.aspx
 

11/19/2008 1:33:46 PM
Gravatar
Total Posts 18439

Re: Random Select Query

In MS SQL the easiest way is to:

ORDER BY newid()

Hope it helps,

Joe

11/19/2008 1:34:59 PM
Gravatar
Total Posts 18439

Re: Random Select Query

oh, thats what you're doing, didn't read carefully. I think it performs well as long as you're not returning huge rowsets.

Joe

You must sign in to post in the forums. This thread is closed to new posts.