Home » SQL & PL/SQL » SQL & PL/SQL » Select Values from table A that are not in table B
Select Values from table A that are not in table B [message #1086] Sat, 30 March 2002 15:35 Go to next message
Jamie
Messages: 5
Registered: March 2002
Junior Member
Hi all, a quick question here. I have two tables Table A (which has userid and name) and Table B (which has userID). I want to get all the names from Table A where there is no matching userID in Table B. Any help in writing this sql would be appreciated.

J
Re: Select Values from table A that are not in table B [message #1087 is a reply to message #1086] Sat, 30 March 2002 21:42 Go to previous messageGo to next message
Robert Kuhlmann
Messages: 35
Registered: March 2002
Member
Hey Jamie,

try this
select userid, from table_a
minus
select userid, from table_b;

Robert
Re: Select Values from table A that are not in table B [message #1104 is a reply to message #1086] Mon, 01 April 2002 11:16 Go to previous messageGo to next message
Todd Barry
Messages: 4819
Registered: August 2001
Senior Member
select name
  from a
 where not exists
   (select null
      from b
     where b.userid = a.userid);
Re: Select Values from table A that are not in table B [message #1106 is a reply to message #1086] Mon, 01 April 2002 11:58 Go to previous message
Jamie
Messages: 5
Registered: March 2002
Junior Member
Thanks, that works for me :)
Previous Topic: Locally Managed TableSpaces
Next Topic: Need SQL for Deleting Tree Data
Goto Forum:
  


Current Time: Thu Mar 28 18:20:46 CDT 2024