Article View: borland.public.interbase.sql
Article #450Re: How to select records not present in either two similar tables
From: Karol Bieniaszewski
Date: Wed, 21 Nov 2007 08:23
Date: Wed, 21 Nov 2007 08:23
37 lines
2227 bytes
2227 bytes
Uzytkownik "Jason Summers" <jason@grinc.org> napisal w wiadomosci news:4743bb74$1@newsgroups.borland.com... > To do queries like that, you can use the IN and NOT IN. > > select * from EMPLOYEETABLE1 where EMPLOYEEID NOT IN (select EMPLOYEEID > from EMPLOYEETABLE2) > > Here's a few more examples of usage: > > // selects all contacts which have not been assigned to a group > select CONTACTID from CONTACTS where CONTACTID NOT IN (select CONTACTID > from CONTACTGROUPMEMBERS) > > or > > // selects all contacts which are in a group > select CONTACTID from CONTACTS where CONTACTID IN (select CONTACTID from > CONTACTGROUPMEMBERS) > > - Jason > > "Leonardo Tansini" <ltansini@katamail.com> wrote in message > news:op.t13wz0jinnuxdn@salaxp... >> In my IB db I've two big employees tables whith the same structure and >> keys. I need to create a query to select the employees present in the >> first table that are not present in the second one. Some help? Regards. above will be very slow on big tables better is select * from EMPLOYEETABLE1 E1 where not exists(select FROM EMPLOYEETABLE2 E2 WHERE E1.EMPLOYEEID=E2.EMPLOYEEID) Karol Bieniaszewski
Technical Details
Message-ID:
<4743e8f5$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<op.t13wz0jinnuxdn@salaxp> <4743bb74$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,69fa63958f1f7eb3 X-Google-Attributes: gid114a0e,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit From: "Karol Bieniaszewski" <liviuslivius@poczta.onet.pl> Newsgroups: borland.public.interbase.sql References: <op.t13wz0jinnuxdn@salaxp> <4743bb74$1@newsgroups.borland.com> Subject: Re: How to select records not present in either two similar tables Date: Wed, 21 Nov 2007 09:23:59 +0100 Lines: 39 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.3138 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198 X-RFC2646: Format=Flowed; Response NNTP-Posting-Host: 195.205.151.58 Message-ID: <4743e8f5$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1195632885 195.205.151.58 (21 Nov 2007 00:14:45 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail