S
shapper
Hello,
How do I select 10 random records from a table?
Thanks,
Miguel
How do I select 10 random records from a table?
Thanks,
Miguel
shapper said:Hello,
How do I select 10 random records from a table?
Thanks,
Miguel
Lasse said:The SQL way is to order by a GUID and select the top 10 rows.
Unfortunately, SQL is made to retrieve the rows you specify, not just
"any 10 rows, doesn't matter which ones".
I'm afraid you're going to have to come up with a way to specify the
10 random rows you want.
Could you for instance retrieve the primary key of all the rows, and
then grab 10 random items from that array and retrieve the full rows
for those keys?
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.