🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.interbase.sql
Article #544

Re: How to select records not present in either two similar tables

#544
From: Jason Summers
Date: Wed, 21 Nov 2007 05:00
24 lines
2013 bytes
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. 
Technical Details
Message-ID: <4743bb74$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.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
References: <op.t13wz0jinnuxdn@salaxp>

Show Full Headers
Complete Article Headers
X-Google-Thread: 114a0e,69fa63958f1f7eb3
X-Google-Attributes: gid114a0e,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
Reply-To: "Jason Summers" <jason@grinc.org>
From: "Jason Summers" <jason@grinc.org>
Newsgroups: borland.public.interbase.sql
References: <op.t13wz0jinnuxdn@salaxp>
In-Reply-To: <op.t13wz0jinnuxdn@salaxp>
Subject: Re: How to select records not present in either two similar tables
Date: Tue, 20 Nov 2007 23:00:34 -0600
Lines: 25
MIME-Version: 1.0
Content-Type: text/plain;
 format=flowed;
 charset="iso-8859-15";
 reply-type=response
Content-Transfer-Encoding: 7bit
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Windows Mail 6.0.6000.16480
X-MimeOLE: Produced By Microsoft MimeOLE V6.0.6000.16545
NNTP-Posting-Host: 64.251.145.50
Message-ID: <4743bb74$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1195621236 64.251.145.50 (20 Nov 2007 21:00:36 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.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