List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:August 27 2001 4:23pm
Subject:Re: selecting what is not in something
View as plain text  
At 9:38 AM -0600 8/27/01, Jeff Shipman - SysProg wrote:
>I have two tables and that have a couple of
>identical columns. I would like to find out
>what of a certain column is in one table and
>not in another. I've tried the following, but
>I get errors:
>
>select col1 from tab1 where col1 not in (select col1 from tab2);
>select tab1.col1 from tab1,tab2 where tab1.col1 not in tab2;
>
>Please tell me how I can do this type of
>query.

Use a LEFT JOIN.

SELECT tab1.col1 FROM tab1 LEFT JOIN tab2 ON tab1.col1 = tab2.col1
WHERE tab2.col1 IS NULL


tab2.col1 must be declared as NOT NULL for this to work.

>
>Jeff Shipman           E-Mail: jeff@stripped
>Systems Programmer     Phone: (505) 835-5748
>NMIMT Computer Center  http://www.nmt.edu/~jeff


-- 
Paul DuBois, paul@stripped
Thread
selecting what is not in somethingJeff Shipman - SysProg27 Aug
  • RE: selecting what is not in somethingJay Fesco27 Aug
  • Re: selecting what is not in somethingPaul DuBois27 Aug