Thread: Order by rand()
View Single Post
Old 06-10-2008, 07:13 PM   #7 (permalink)
Jmz
The Acquainted
 
Join Date: Oct 2007
Location: Newcastle, UK
Posts: 113
Thanks: 3
Jmz is on a distinguished road
Default

Thanks for the answers, I still have a few questions about how the query is actually executed.

Say I have a query that says:
Quote:
SELECT * FROM tbl_gallery WHERE fld_userid = $UserID ORDER BY RAND() LIMIT 4
I understand (from what I've read) that the database will shuffle the rows and select 4 at random, but will the WHERE clause be executed first? Would it pick the rows that meet the where criteria and then shuffle them and select the 4 or does it shuffle all the rows and select 4 and then check the where clause?
__________________
Free CSS Tutorials
Send a message via MSN to Jmz
Jmz is offline  
Reply With Quote