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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:16:02+00:00 2026-06-13T02:16:02+00:00

I have three tables. The first two tables have similar data but they come

  • 0

I have three tables. The first two tables have similar data but they come from different sources and they do not have the same amount of columns. I am using the third table to gather data from the other two tables. I would like a column in the third table that has the name of the table that the data came from.

Example:
table_1 contains the following data in the following order.

(ID, data_1, data_2, data_3, data_4, data_5)

table_2 contains the following data in the following order.

(ID, data_3, data_1, data_5, data_2, data_4, data_6, data_7)

I gather the data I need from both tables, table_3 has the same amount of columns as table_1.

First from table_1

INSERT INTO table_3
SELECT * FROM table_1

Then from table_2

INSERT INTO table_3
SELECT ID, data_1, data_2, data_3, data_4, data_5
FROM table_2

This is working and I have no problem with it. I would like to create a column in table_3 however that holds the name of the table that the data was taken from. I am not sure how to go about this. I added another column to table_3 so it now has a col_6 and then thought I could update that column manually but it is not working. This is what I tried.

UPDATE table_3
SET col_6 = 'table_1'
WHERE table_3.col_1 = table_1.col_1

UPDATE table_3
SET col_6 = 'table_2'
WHERE table_3.col_1 = table_2.col_1

Any help with this would be great, thank you.

  • 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-06-13T02:16:02+00:00Added an answer on June 13, 2026 at 2:16 am

    AFAIK, there’s no way to do this automatically

    but you can do something like this:

        insert into table_3
        select t.*, 'table_1'
        from table_1
    

    I’m not sure wahat Column_1 in your update statements reprsesent though.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables I need to join. The first two are easy and
I have three tables. I have to retrieve the data using Linq statement. My
I have three tables of data: table: cars [10,000 rows] table: planes [2,000 rows]
I have three tables Author, Book and AuthorBook. AuthorBook table only contains two foreign
I'm going to work on a Customer Profiling project (similar but not same to
I found some questions that looked similar, but not exactly the same so I'll
I have two applications : the first one inserts data in the table MyTable
I have two tables. Table A +----+-------+--------+-------+-------+ | ID | First | Middle |
I have a tree table with two columns on a page. The first one
I have an issue in entity framework code first, three table in database as

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.