Re: Which query is more correct?

From: Date: Fri, 20 Nov 2009 22:42:34 +0000
Subject: Re: Which query is more correct?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-300000@lists.php.net to get a copy of this message
On Fri, 2009-11-20 at 16:41 -0600, LAMP wrote: > Hi, > I need to pull all records from the table Registrants they are NOT in > the table ToBeRecleared > > Registrants.Reg_ID is PK > ToBeRecleared.tbrc_Reg_ID is PK > > Which query is more correct? > > SELECT r.* > FROM registrants r > where r.reg_status=1 AND r.reg_id NOT IN (SELECT tbrc_reg_id FROM > toberecleared) > > > SELECT r.* > FROM registrants r > where r.reg_status=1 AND (SELECT count(*) FROM toberecleared where > tbrc_reg_id=r.reg_id) = 0 > > I checked explain of bot queries - but can't "read" them. :-) > > Thanks, > L > I'd go with the first, just because thats how I'd code it if I was doing this myself, as it just makes more sense to the way I write my queries Thanks, Ash http://www.ashleysheridan.co.uk

« previous php.general (#300000) next »