[SQL] Related table question

Ruslan Zasukhin sunshine at public.kherson.ua
Tue Jan 20 20:40:56 CST 2004


on 1/18/04 8:20 PM, Eric Forget at forgete at cafederic.com wrote:

> 15)
>   a.RecID in (select ptr from keyword where name = 'Me')
> OR
>   a.RecID not in (select ptr from keyword where name <> 'YOU')
> 
>   Result:     CalcID      Label
>               1           2
>               3           7
>               4           6
> 
> Instead of:     CalcID      Label
>               1           2
>               2           3
>               3           7
>               4           6


Note, that we need get something as

select A.calcId, A.label
from a
where a.RecID in (1) OR
      NOT (a.RecID in (1,2))


By the way, Eric, it is a way -- that at first you make query,
Then build list of RecIDs and execute second query.


ANSWER FOR YOU 

select A.calcId, A.label
from a
where 
    a.RecID in (select ptr from keyword where name = 'Me')
OR 
   NOT( a.RecID in (select A.RecID
                    FROM A, keyword,
                    WHERE A.RecID = keyword.ptr and name <> 'YOU')
      )





-- 
Best regards,
Ruslan Zasukhin      [ I feel the need...the need for speed ]
-------------------------------------------------------------
e-mail: ruslan at paradigmasoft.com
web: http://www.paradigmasoft.com

To subscribe to the Valentina mail list go to:
http://lists.macserve.net/mailman/listinfo/valentina
-------------------------------------------------------------



More information about the Valentina mailing list