pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Exner, Peter <Exner@his.de>
To: Richard Broersma Jr <rabroersma@yahoo.com>
To: SQL Postgresql List <pgsql-sql@postgresql.org>
Subject: Re: How to find entries missing in 2nd table?
Date: Wed, 12 Jul 2006 10:06:34 +0200
Message-ID: <507847EF2B23D748BAC77799DA52D0EC6FD63F@mailbox.his.de> (raw)

Hi, 

what about

SELECT controller_id FROM control
WHERE controller_id NOT IN
(SELECT DISTINCT controller_id FROM datapack);

?

Regards
Peter



> -----Ursprüngliche Nachricht-----
> Von: pgsql-sql-owner@postgresql.org 
> [mailto:pgsql-sql-owner@postgresql.org] Im Auftrag von 
> Richard Broersma Jr
> Gesendet: Dienstag, 11. Juli 2006 19:04
> An: SQL Postgresql List
> Betreff: Re: [SQL] How to find entries missing in 2nd table?
> 
> 
> 
> --- Richard Broersma Jr <rabroersma@yahoo.com> wrote:
> 
> > > >> I need to get all entries from the table control that are not 
> > > >> listed in datapack.
> > > > 
> > > > SELECT C.CONTROLLER_ID
> > > > 
> > > > FROM CONTROL AS C 
> > > >   LEFT JOIN DATAPACK AS D ON ( C.CONTROLLER_ID = 
> D.CONTROLLER_ID)
> > > > 
> > > > WHERE D.CONTROLLER_ID IS NULL;
> > > > 
> > > 
> > > 
> > > Or
> > > (SELECT controller_id FROM control)
> > > EXCEPT
> > 
> > Good point!  But don't forget to include the list. :-)
> > 
> > Regards,
> > 
> > Richard Broersma Jr.
> > > (SELECT controller_id FROM datapack) ?
> > > 
> > > --
> > > Milen A. Radev
> > > 
> > 
> > 
> 
> 
> ---------------------------(end of 
> broadcast)---------------------------
> TIP 9: In versions below 8.0, the planner will ignore your desire to
>        choose an index scan if your joining column's datatypes do not
>        match
> 



view thread (13+ messages)  latest in thread

Message-ID: <507847EF2B23D748BAC77799DA52D0EC6FD63F@mailbox.his.de>
Permalink:  ../507847EF2B23D748BAC77799DA52D0EC6FD63F@mailbox.his.de/
Also on:    postgresql.org/message-id/507847EF2B23D748BAC77799DA52D0EC6FD63F@mailbox.his.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: Exner@his.de, rabroersma@yahoo.com
  Subject: Re: How to find entries missing in 2nd table?
  In-Reply-To: <507847EF2B23D748BAC77799DA52D0EC6FD63F@mailbox.his.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox