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

  • Home
  • SEARCH
  • 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 6160295
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T21:16:33+00:00 2026-05-23T21:16:33+00:00

Currently looking to extract data from 2 tables and insert into another. Tables as

  • 0

Currently looking to extract data from 2 tables and insert into another.
Tables as follows (with example ideal data):

Table1
T1ID(PK)  T1Field1
301       2011-07-01
302       2011-07-01

Table2
T2ID(PK)  T2Field2  T2Field3  T2Field4
521       301       555       Apple
522       301       666       Pear


Table3 (new table)
T3Field1  T3Field2     T3Field3    T3Field4
301       2011-07-01   555         Apple
301       2011-07-01   666         Pear

Looking for the fewest and most efficient query’s to use in order to do the following:

  1. Insert T1ID into T3Field1 + Insert T1Field1 into T3Field2

  2. Update T3Field3 where T3Field1 = T2Field2 (for each) -*

Have simply used mysql insert for the first query. This NEEDS to be done first as it contains timestamp information.

*Attempted INNER JOIN here with no luck since there is a one-to-many and only the first row would get inserted.

I could select all of the results and then while loop / update within for each record but am trying to keep this as minimal as possible.

Just need a second opinion on the logic!

  • 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-23T21:16:34+00:00Added an answer on May 23, 2026 at 9:16 pm

    I tested the below code and it matches your ideal data. But, second row of Table1 is lost since there is no corresponding match for it in Table2

    INSERT INTO Table3
    SELECT 
    Table1.T1ID AS T3Field1,
    Table1.T1Field1 AS T3Field2,
    Table2.T2Field3 AS T3Field3,
    Table2.T2Field4 AS T3Field4
    FROM Table1, Table2
    WHERE
    Table1.T1ID = Table2.T2field2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently looking for a grid-like interface, that you can insert into a
I was currently looking into memcached as way to coordinate a group of server,
I'm currently looking at indexing an ASP website from Sharepoint and I need to
I'm currently looking into unit testing for a new application I have to create.
I'm looking to enable users to import data from websites, without giving away too
Hey, I'm currently trying to extract information from a 3d array, where each entry
I've been looking around for a way to convert Facebook Graph API Data into
I am looking to extract the camera related information from a jpg using Java.
I'm currently looking at the Python framework Django for future db-based web apps as
We are currently looking to adopt some type of standard developer framework and have

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.