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 4065368
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T15:58:27+00:00 2026-05-20T15:58:27+00:00

I am new to mySQL and would like some help with a query I’m

  • 0

I am new to mySQL and would like some help with a query I’m running. I’d like to update a newly created table with fields from existing tables. Here is what I’m working with.

UPDATE NEW_TABLE new, OLD_TABLE_1 one, OLD_TABLE_2 two, OLD_TABLE_3 three
SET
new.COLUMN_1 = one.COLUMN_1,
new.COLUMN_2 = one.COLUMN_2,
new.COLUMN_3 = one.COLUMN_3,
new.COLUMN_4 = two.COLUMN_1,
new.COLUMN_5 = two.COLUMN_2,
new.COLUMN_6 = three.COLUMN_1,
new.COLUMN_7 = three.COLUMN_2
WHERE
  three.COLUMN_1 = two.COLUMN_1 AND
  three.COLUMN_2 = one.COLUMN_1;

My data is all HR data. OLD_TABLE_1 is address information, OLD_TABLE_2 is medical information, and OLD_TABLE_3 is the original HR data.
In the where clause, three.COLUMN_1 has a relationship with two.COLUMN_1. Imagine that three.COLUMN_1 is the user’s ID and it maps to a user’s ID in two.COLUMN_1. Also imagine that three.COLUMN_2 is a user’s home phone number that maps to a user’s home phone number in one.COLUMN_1. When the data is entered into the new table, I only want data for a unique individual.
The reason for creating a new table is to optimize reporting. Drawing data from three tables is time consuming. I have large tables over 150GB in size. If I can load the data I need into a temp table, the query will run much quicker.

Any help would be greatly appreciated. Thanks in advance.

  • 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-20T15:58:27+00:00Added an answer on May 20, 2026 at 3:58 pm

    If this is a brand new table, you’d want to INSERT instead of UPDATE.

    INSERT INTO NEW_TABLE
        (COLUMN_1, COLUMN_2, COLUMN_3, COLUMN_4, COLUMN_5, COLUMN_6, COLUMN_7)
        SELECT one.COLUMN_1, one.COLUMN_2, one.COLUMN_3, two.COLUMN_1, two.COLUMN_2, three.COLUMN_1, three.COLUMN_2
            FROM OLD_TABLE_1 one
                INNER JOIN OLD_TABLE_3 three
                    ON one.COLUMN_1 = three.COLUMN_2
                INNER JOIN OLD_TABLE_2 two
                    ON three.COLUMN_1 = two.COLUMN_1
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very, very new to MYSQL.I tried to create a table named option.
I want to add a new time-field to a an existing MySQL-table that is
I'm new to MySql and to databases in general. I have a query, which
I'm having a problem with this query for some reason: $this->db->query(UPDATE schools SET name
I am new to MySQL and PHP(as you can probably tell) and I was
I am fairly new to MySQL and have a project in which I need
I'm quite new to subject of writting stored function for mySQL database, hence i'm
I used a new Date() object to fill a field in a MySQL DB,
Solved: Was missing view parameter for postData(), changed to reflect this. I would like
I'm super new to programming and I've been using appengine to help me learn

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.