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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T17:39:40+00:00 2026-05-28T17:39:40+00:00

I have two tables almost identical: employee employee_history The second table has two additional

  • 0

I have two tables almost identical:

  • employee
  • employee_history

The second table has two additional fields.

I would like to copy a record from employee into employee_history using an INSERT with a subquery. Sort of like this:

INSERT INTO employee_history SELECT * FROM employee WHERE id = idQ   

My problem is that I need to add information into the 2 fields employee_history has that employee does not have:

  • update_code
  • date_of_change.

Is there a way I can copy a record from employee into employee_history keeping it simple like with the above insert statement while adding the 2 new pieces of data?

  • 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-28T17:39:41+00:00Added an answer on May 28, 2026 at 5:39 pm

    Alias the employee table and select all the columns then add the two new columns wherever they fit (at the beginning or end of the list):

    INSERT INTO employee_history SELECT e.*, 'x', 'y' FROM employee e WHERE id = idQ;
    

    You need to alias the table because you would get an error (ORA-00923: FROM keyword not found where expected) if you ran it as such:

    INSERT INTO employee_history SELECT *, 'x', 'y' FROM employee WHERE id = idQ;
    

    The problem would be if your two additional columns in the employee_history table were in the middle of the list of columns in the employee table. In that case you’d have to individually select each column.

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

Sidebar

Related Questions

I have two tables, 'photos' and 'videos'. Together they are almost identical, except one
I have two tables that are joined together. A has many B Normally you
I have two tables, both with start time and end time fields. I need
I have two tables: Table 1: ID, PersonCode, Name, Table 2: ID, Table1ID, Location,
I have two tables which get updated at almost the exact same time -
I have two tables: Messages - Amongst other things, has a to_id and a
I have two tables: a source table and a target table. The target table
I have two tables: a WorkItem table, and a WorkItemNote table. How do I
I have two tables lets say employees and order, both table have millions of
I have two methods that are almost identical. The only dffernece is the where

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.