Microsoft Access Query Records On One Table But Not Another

nicholas conger 1 Reputation point
2021-04-21T14:12:05.993+00:00

Hello,

I had a quick question about a Microsoft Access Query we're trying to write. Our DBAs all left, so we're trying to piecemeal something for a department.

We have 2 tables:

Table 1

  • EID
  • Email
  • PW

Table 2

  • EID
  • Demographics Info

Our key is EID. We want to run a query to find the EID on Table 2 that isn't on Table 1.

On Query Design View, I'm including everything on Table 2, but adding the Email and PW from Table 1.

The query shows everything, but it doesn't include the info from Table 2 that doesn't have Email/PW from table 1.

The idea is to query out the info from Table 2 that do NOT have a Email/PW from Table 1. Get that info, add it to table 1 and rerun the query to fill every value on Table 2 with that Email/PW info.

If there a way to edit the query to ONLY show the info on Table 2 that doesn't have values from table 1? Trying all sorts of criteria and not coming up with anything.

Thanks.

Access Development
Access Development
Access: A family of Microsoft relational database management systems designed for ease of use.Development: The process of researching, productizing, and refining new or existing technologies.
881 questions
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Ken Sheridan 2,841 Reputation points
    2021-04-21T17:32:28.107+00:00

    SELECT EID
    FROM [Table 2]
    WHERE NOT EXISTS
    (SELECT *
    FROM [Table 1]
    WHERE [Table 1].EID = [Table 2].EID);

    0 comments No comments

  2. nicholas conger 1 Reputation point
    2021-04-21T22:35:37.01+00:00

    That worked BEAUTIFUL.

    one more question, is there a way to export all of table 2 and not just the EID from EID missing from Table 1 ?

    0 comments No comments

  3. DBG 2,301 Reputation points
    2021-04-22T17:15:49.083+00:00

    Maybe you could try something like:

    SELECT Table2.* FROM Table2
    LEFT JOIN Table1
    ON Table2.EID=Table1.EID
    WHERE Table1.EID Is Null
    

    Hope that helps...

    0 comments No comments

  4. Ken Sheridan 2,841 Reputation points
    2021-04-23T12:32:52.883+00:00

    You can return all columns by using the asterisk wildcard character in the SELECT clause in place of the column names, as in thedbguy's reply.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.