Re: Quick SQL Question

From: Date: Wed, 18 Jun 2003 01:44:01 +0000
Subject: Re: Quick SQL Question
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-151925@lists.php.net to get a copy of this message
> 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/

« previous php.general (#151925) next »