Re: A mysql question...

From: Date: Thu, 21 Oct 2010 13:46:27 +0000
Subject: Re: A mysql question...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-308932@lists.php.net to get a copy of this message
On 21 October 2010 14:13, Midhun Girish <midhungirish@gmail.com> wrote: > | Name | phone |userid| > > +------------+--------------+------+ > > | Mr Sasi | 01225 708225 | 1 | > > | Miss Brown | 01225 899360 | 2 | > > | Mr Black | 01380 724040 | 3 | > > +------------+--------------+------+ > Table B > > +------------+--------------+ > > | blockedbyid| blockedid | > At first glance ... SELECT A.UserID, A.Name, A.Phone FROM A WHERE A.UserID NOT IN ( SELECT B.BlockedID FROM B WHERE B.BlockedByID = x ) The Subselect finds all the user ids blocked by x. The main select finds all users who are NOT in the subselects list. I'm pretty sure a subselect isn't as efficient as it could be though. -- Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY

« previous php.general (#308932) next »