miniBB ® miniBB®
miniBB Support Forums
 | Forums | Register | Reply | Search | Statistics | Manual |
Specific miniBB Support Forums / Specific /   

Select random rows in $Tt

Author tkx211
Registered
#1 | Posted: 28 Oct 2011 16:28 | Edited by: tkx211 
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
Registered
#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 Top

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

 Short link for this topic:

 ?
Only registered users are allowed to post here. Please, enter your username/password details upon posting a message, or register first.


Before posting, make sure your message is compliant with our forum posting rules. If not, it may be locked or deleted with no explanation.
 
miniBB Support Forums Powered by Forum Software miniBB ® Features  Requirements  Demo  Download  Showcase  Gallery of Arts
Compiler  Premium Extensions  Premium Support  License  Contacts
Check out the Captcha add-on: protect your miniBB-forums from the automated spam and flood.
Captcha Addon for miniBB