Click to See Complete Forum and Search --> : selecting randomly with SQL


RabBell
01-29-2008, 01:17 PM
I'm looking for a bit of SQL code that will select some entries randomly from an SQL table.

For instance I'd like to feed a parameter in that contains the number 20, and the returned record contains 20 randomly and distinct selected records.

Anyone know how this can be done? (never came across randomly select records)

Any helps appreciated

:)

chazzy
01-29-2008, 09:32 PM
there's nothing in the ansi standard about random ordering and limiting results. As such, you'll need to write a query that's database specific, so we can only tell you if you tell us what dbms you use.

NogDog
01-29-2008, 09:55 PM
If you are using MySQL, you might want to read this PHPBuilder.com thread (http://phpbuilder.com/board/showthread.php?t=10338930).