Query to solve if...

E

elli

I have two tables. I want to check if the Computer -table's User ID exicts
in User table. Probably very simple..., but so am I..;)

-elli-
 
K

Ken Snell \(MVP\)

How do you want to use this value? Where are you wanting to look it up? That
will help us help you to use the appropriate approach.
 
E

elli

I've been doing a new database from a huge and messy 1-2-3 with multiple
entries with some smalla differencies. While cleaning the table, I might
have left some of the Computers with a user ID that doesn't exist in User
table anymore, because I 'cleant' it. I mean there where same
User name with many ID-numbers, and I changed in the computer table them to
be the same and deleted the 'overcomes' from the User table. Just need to
check that there aren't any computers without an existing user.

Sorry my messy explanation....

-elli-
 
E

elli

I forgot to mention that I don't need it it more than once. And can do the
fix manually, just need to now those ComputerID's without a proper User..

-e-
 
K

Ken Snell \(MVP\)

OK .... in ACCESS, there is a query wizard that will create a query for you
to find "unmatched" records. That is the easiest way to do what you seek.
Try it, and post back with additional questions.
 
E

elli

Hi there! Thank You for your answer... I know Access can do almost anything
one can desire, but I have a problem not knowing it's potentials and
functions.

I know the query wizard, and done queries with it, but to accomplish this
problem I am lost.

But thank You for your help.

-elli-
 
K

Ken Snell \(MVP\)

What is confusing you in the wizard? It should lead you through each step
fairly easily. You tell it that you want the Computers table to be the
results for the query, then you tell it you want the Users table as the one
that contains the related records, then you select the fields in both tables
that would be related/linked (UserID?), then you specify the fields from
Computers table that you want the query to show you, and then you are done.

Otherwise, assuming that the names I've listed above are correct, this is
the SQL statement of the query to show all Computer records containing a
UserID that does not exist in the Users table:

SELECT Computers.*
FROM Computers
LEFT JOIN Users
ON Computers.UserID = Users.UserID
WHERE Users.UserID Is Null;
 
E

elli

Thank You Ken very much for your help. The SQL did it, and I could fix two
pieces of info:)) U made my day!

Take care
-e-
 
Top