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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:54:55+00:00 2026-05-17T16:54:55+00:00

UPDATE : Adding more Employee and ReplacementEmployee Table Employee – EmployeeId SerialNo —————————– 1

  • 0

UPDATE: Adding more Employee and ReplacementEmployee

Table Employee –

 EmployeeId   SerialNo
 ----------------------------- 
 1             11111  
 34            23233    
 23            13234  

Table ReplacementEmployee–

 ReplacementId   SerialNo
 ----------------------------- 
 11            11111  
 23            23233    
 13            13234  

So when I join these tables on Serial No. have something like this Mapping Table –

 EmployeeId   ReplacementId
 ----------------------------- 
 1             11    
 34            23    
 23            13  

So now I have insert all the data from table something like this OrignalTable and it can have multiple values for EmployeeId-

 EmployeeId   Name
 ----------------------------- 
 1             AAA    
 34            BBB    
 23            CCC  
 1             AAA

Into an table with different schema with basically something like this InsertTable and it can have multiple values for EmployeeId-

ReplacementId       Name
------------------------------- 
 11                AAA   
 23                BBB
 13                CCC  
 11                AAA

So if you look at the problem I need to insert data from one table to other but I need to insert a different field i.e. in this case I need to insert the corresponding ReplacementId instead of the EmployeeId in the new table. So can anyone suggest me how would I go about writing such a query ?

  • 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-17T16:54:55+00:00Added an answer on May 17, 2026 at 4:54 pm

    Try this:

    INESRT INTO InsertTable (ReplacementID, [Name])
    SELECT R.ReplacementID, O.[Name]
    FROM OriginalTable O
    INNER JOIN Employee E ON E.EmployeeID = O.EmployeeID
    INNER JOIN ReplacementEmployee R ON E.SerialNo = R.SerialNo
    

    And if you only want ONE instance of each employee in the InsertTable, use SELECT DISTINCT instead

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

Sidebar

Related Questions

I'm having trouble dynamically adding controls inside an update panel with partial postbacks. I've
I am considering adding validation on some insert and update statements for MS SQL
Update: giving a much more thorough example. The first two solutions offered were right
Update : this is more-or-less a dupe , and it turns out to be
Update: Solved, with code I got it working, see my answer below for the
Update: Check out this follow-up question: Gem Update on Windows - is it broken?
UPDATE: Focus your answers on hardware solutions please. What hardware/tools/add-in are you using to
Update : Looks like the query does not throw any timeout. The connection is
Update: Now that it's 2016 I'd use PowerShell for this unless there's a really
UPDATE - A comprehensive comparison, updated as of February 2015, can be found here:

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.