> Here it is:
> 
> SELECT penpals.username, penpals.zoneid, penpals_photos.album,
> penpals_photos.rating, zones.zone_id, zones.zone_code,
> penpals_photos.filename, penpals.city
> FROM penpals, penpals_photos, zones
> WHERE penpals.username = penpals_photos.album AND penpals_photos.rating !=
> 'X' AND penpals.zoneid = zones.zone_id
> ORDER BY RAND() LIMIT 0,1

If it's the username that is to be random, I'd grab it first then go get all 
the other data with a second query.  If that is undesirable for whatever reason 
then I'd use left joins so as to select much less data.

As an aside, limit 0,1 is the same as limit 1.


-- 
Greg Donald
http://destiney.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to