Reply to Re: SELECT a random 10 records from table....easy newbie question

Your name:

Reply:


Posted by Marcin A. Guzowski on 08/16/07 11:17

WhytheQ pisze:
> This doesn't work:
>
> --****************************************
> USE myDatabase
> SELECT TOP 10 *
> FROM myTable
> WHERE NEWID()
> --****************************************
>
> ..I know I need to use the function newID() to find random records -
> just don't know where it fits in the query (suspect the TOP will need
> to go from the above)
>
> Any help greatly appreciated

Replace "WHERE" with "ORDER BY":

SELECT TOP 10 *
FROM myTable
ORDER BY NEWID()

IMHO this query won't be efficient against large tables.


--
Best regards,
Marcin Guzowski
http://guzowski.info

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация