miniBB ® 

miniBB

®
Support Forums
  
 | Start | 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:28 
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 Developer 
#2 | Posted: 28 Oct 2011 17:55 
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:52 
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:13 
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


  ?
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
Try the Captcha add-on: protect your miniBB-forums from the automated spam and flood.


  ⇑