Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 827523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T03:35:17+00:00 2026-05-15T03:35:17+00:00

I have an Access database that has two tables that are related by PK/FK.

  • 0

I have an Access database that has two tables that are related by PK/FK. Unfortunately, the database tables have allowed for duplicate/redundant records and has made the database a bit screwy. I am trying to figure out a SQL statement that will fix the problem.

To better explain the problem and goal, I have created example tables to use as reference:
alt text http://img38.imageshack.us/img38/9243/514201074110am.png
You’ll notice there are two tables, a Student table and a TestScore table where StudentID is the PK/FK.

The Student table contains duplicate records for students John, Sally, Tommy, and Suzy. In other words the John’s with StudentID’s 1 and 5 are the same person, Sally 2 and 6 are the same person, and so on.

The TestScore table relates test scores with a student.

Ignoring how/why the Student table allowed duplicates, etc – The goal I’m trying to accomplish is to update the TestScore table so that it replaces the StudentID’s that have been disabled with the corresponding enabled StudentID. So, all StudentID’s = 1 (John) will be updated to 5; all StudentID’s = 2 (Sally) will be updated to 6, and so on. Here’s the resultant TestScore table that I’m shooting for (Notice there is no longer any reference to the disabled StudentID’s 1-4):
alt text http://img163.imageshack.us/img163/1954/514201091121am.png
Can you think of a query (compatible with MS Access’s JET Engine) that can accomplish this goal? Or, maybe, you can offer some tips/perspectives that will point me in the right direction.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T03:35:17+00:00Added an answer on May 15, 2026 at 3:35 am

    The only way to do this is through a series of queries and temporary tables.

    First, I would create the following Make Table query that you would use to create a mapping of the bad StudentID to correct StudentID.

    Select S1.StudentId As NewStudentId, S2.StudentId As OldStudentId 
    Into zzStudentMap
    From Student As S1
        Inner Join Student As S2
            On S2.Name = S1.Name
    Where S1.Disabled = False
        And S2.StudentId <> S1.StudentId
        And S2.Disabled = True
    

    Next, you would use that temporary table to update the TestScore table with the correct StudentID.

    Update TestScore
        Inner Join zzStudentMap
            On zzStudentMap.OldStudentId = TestScore.StudentId
    Set StudentId = zzStudentMap.NewStudentId
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Microsoft Access database and I have two tables. Table1 has a
I have two tables in my access database that I want to be able
so I have this problem. My Database has two tables that look something like
I have access of a database which has two tables. These two tables have
I have a ms access database that has one table for each photo album
I have a user Sql Authentication account that has remote access to my database
I have two database tables: 'MyTable' which has a standard auto-incrementing primary key integer
I have two tables in an MS Access 2010 database: TBLIndividuals and TblIndividualsUpdates. They
I have an Access 2007 database that works asynchronously with a MAS200 database. Due
Just need some quick clarification I have 2 Queries in my Access Database that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.