miniBB ®

miniBB

®
Support Forums
  
 · Start · Sign in · Register · Search · Statistics · File Bank · Manual ·
Specific miniBB Support Forums / Specific /  
 

Select random rows in $Tt

 
Author tkx211
Partaker
#1 · Posted: 28 Oct 2011 16:28Reply Quote
I want to make a list of 10 random rows in $Tt. Because some old topics maybe interested for somebody, example in a poem/ story forum, But I don't know how to query MySql. I don't want to run 10 queries at once. Can you help me? Thank you very much.

Author Paul
Lead Lead Developer
#2 · Posted: 28 Oct 2011 17:55Reply Quote
I think, you don't have to run 10 queries, but just make a "random" order.

select * from {$Tt} order by rand() limit 10;
is probably about what you need...

Author tkx211
Partaker
#3 · Posted: 28 Oct 2011 18:52Reply Quote
Thanks.
But can 'order by rand()' take several seconds? Because it sort all rows then choose only 10 rows

Author Guest
~
#4 · Posted: 28 Oct 2011 19:13Reply Quote
SELECT * FROM $Tt WHERE (ABS(CAST((BINARY_CHECKSUM(*)*RAND()) as int)) %100) < 10

Specific miniBB Support Forums / Specific /
 Select random rows in $Tt
 Share Topic's Link

Your Reply Click this icon to move up to the quoted message

BB code for the Bold StyleBB code for the Italic StyleBB Code for the PictureBB code for the URLUpload a File

  ?
Post as a Guest, leaving the Password field blank. You could also enter a Guest name, if it's not taken by a member yet. Sign-in and post at once, or just sign-in, bypassing the message's text.


Before posting, make sure your message is compliant with forum rules; otherwise it could be locked or removed with no explanation.

 

 
miniBB Support Forums Powered by Forum Software miniBB ® Home  Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contact Us
Check out the File and Picture Attachments add-on: extend your miniBB-forums, attaching images and files.