Subject Re: [firebird-support] Re: Basic SQL Update query question
Author Milan Babuskov
Svein Erling Tysvaer wrote:
> Moreover, not every IN can be translated to EXISTS (or rather, not every
> NOT IN can be translated to NOT EXISTS):
>
> select * from rdb$database r1
> where r1.rdb$security_class not in
> (select r2.rdb$security_class from rdb$database r2)
>
> doesn't return any record in my database, whereas
>
> select * from rdb$database r1
> where not exists
> (select * from rdb$database r2
> where r1.rdb$security_class = r2.rdb$security_class)
>
> returns the record (in my database security_class IS NULL, I don't know
> if it ever has a value).

select * from rdb$database r1
where
r1.rdb$security_class is not null and not exists
(select * from rdb$database r2
where r1.rdb$security_class = r2.rdb$security_class)

or

select * from rdb$database r1
where not exists
(select * from rdb$database r2
where r1.rdb$security_class = r2.rdb$security_class
and r1.rdb$security_class is not null)

--
Milan Babuskov
http://swoes.blogspot.com/
http://www.flamerobin.org