In the below query, the results first row is usually the same 3-4
tracks out of 30.
so should I use PHP to generate a random seed, $r, and pass that to the
query ?
ORDER BY RAND($r)
or, can it be done just with mysql
many thanks
g
On Oct 3, 2005, at 10:15 AM, Michael Stassen wrote:
Graham Anderson wrote:
is there a way to make ORDER BY RAND() a bit more spontaneous ?
I am using it in a php statement:
$sql = "SELECT media.id,
artist.name as artist,
artist.spanish as bio,
artist.purchaseLink,
artist.picture,
media.spanish as trackName,
media.path,
media.quality,
mediaType.id as mediaType
FROM artist, media, playlistItems, mediaType
WHERE playlistItems.playlist_id = $myID
AND playlistItems.media_id = media.id
AND media.artist_id = artist.id
AND media.mediaType_id = mediaType.id
ORDER BY RAND() LIMIT 0, 30";
the result seems to be pretty predictable ....
is there a way to improve RAND() or is there something better ?
Should I be using php to randomize the found set instead ?
many thanks
g
I don't think anyone can answer this, as is. RAND() is meant to
produce a pseudo-random sequence that is not truly random in the
mathematical sense, but which is usually good enough for what you
appear to be doing. The manual
<http://dev.mysql.com/doc/mysql/en/mathematical-functions.html> puts
it this way, "RAND() is not meant to be a perfect random generator,
but instead a fast way to generate ad hoc random numbers that is
portable between platforms for the same MySQL version."
What is your standard for randomness? What do you mean by "the result
seems to be pretty predictable"? Put another way, what are you
expecting, and what are you getting?
Michael
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]