comparing tables

G

Guest

Does anyone know how I could find all the values in one table that are not in another?
I have a table named login; the fields are ID, first_name, last_name...
I have another table named tb; the fields are ID, tb_ID, and last_tbdate.
Here's the relationship: ID.login ----------> tb_ID.tb
The ID fields in both tables are unique key autonumber.
EX. login:
ID first_name last_name
1 jeremy scott
2 john doe
3 jane michaels
4 brian peterson
5 bill gates

EX. tb
ID tb_ID last_tbdate
1 1 09/02/2003
2 1 09/01/2002
3 3 09/05/2004
4 5 09/10/2003
5 5 09/10/2002

The answer should be:
first_name last_name
john doe
brian peterson

because neither john nor brian have any records in the tb table.
i can't seem to get this to work and any halp would be much appreciated thanks
 
T

Tonín

SELECT login.first_name, login.last_name
FROM login LEFT JOIN tb ON login.ID = tb.tb_ID
WHERE tb.tb_ID Is Null;


Tonín
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top