Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find values in one table that are NOT in another table 1

Status
Not open for further replies.

mbowler9

IS-IT--Management
Sep 8, 2003
105
US
I have two tables, one represents information about servers. Each server will have an SA. So it looks like:

CPU table
SERVERS SAs
server1 id1
server2 id2
servre3 id1

I also have a table of users. These are people who are allowed to log in and change the information about the servers. It looks like:

USER Table
ID NAME
id1 name1
id3 name3
id5 name5

I need a query that will tell me which id's are in the CPU table, that do not have a user account (USER table).

Any suggestions on how to do this?

Thanks
 
Try
Code:
Select CPU.*
From CPU LEFT JOIN [USER] ON CPU.ID = [USER].ID
Where [USER].ID IS NULL
I've put USER in brackets because it is (I think) a reserved word.
 
A simple unmatched query will do the trick between the two tables.

SELECT table1.ID, table1.comp
FROM table1 LEFT JOIN table2 ON table1.ID = table2.ID
WHERE (((table2.ID) Is Null));
 
The LEFT JOIN tells you to display all records from table1....the ON tells you to display the records where the ID's are Equal and the WHERE statement tells you to only show those that don't have an ID in table2 therefore giving you all records that don't match based on ID
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top