* scott 
> Hi gang
> Need to get all items that are not in id supplied
> 
> For example select * from test where id!=2 will do this but it will also
> return values that are in 2 if they are also in another id!=2
> In my example if I used the above query I would get
> 10,11,12,13,14,17,18,19,20,17,21,22,23
> 
> I would not want the 10 or the 17 (x2) as they are also in id2!

Try something like this:

  select t1.* 
    from test t1 
    left join test t2 on 
      t2.id=2 and 
      t2.item=t1.item 
    where t2.id is NULL;

-- 
Roger
sql

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to