Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Populating a table from two other tables

Posted on 2014-12-11
3
Medium Priority
?
86 Views
Last Modified: 2014-12-11
I need to populate a table named "TargetTable". The data to populate the table
will come from two different tables. One named Table1 and another named Table2 .
I need to tage the FUAD_ITS_CLERK_ID data from Table1 and the PSUS_USER_NUM
value from Table2 and put it into the target table. I am just lost when it comes to
figuring out the query for this. I know how to join the two tables, but not how to get
the end result of populating TargetTable. Can someone help me?


Table1 -- Spreadsheet
PSUS_USER_ID     FUAD_ITS_CLERK_ID    

s611581          CRAB                
c611689               LEXY                
y657888          MUNC                


Table2 -- SMT_ADMN_PSUS_PR_STE_USERS
PSUS_USER_NUM    PSUS_USER_ID
1                s611581
2                c611689
3                y657888


TargetTable -- Currently no data
PSUS_USER_NUM   FUAD_ITS_CLERK_ID





TargetTable -- After a query is run to populate TargetTable
PSUS_USER_NUM    FUAD_ITS_CLERK_ID
1                CRAB
2                LEXY
3                MUNC
0
Comment
Question by:brgdotnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 13

Accepted Solution

by:
Koen Van Wielink earned 2000 total points
ID: 40495377
Assuming that you're already able to get the data out of the spreadsheet and into your SQL database, this query should do it.

insert into yourTargetTable
select		b.PSUS_USER_NUM
		,	a.FUAD_ITS_CLERK_ID
from	yourTable1 a
		inner join yourTable2 b
			on a.PSUS_USER_ID = b.PSUS_USER_ID
			
select *
from	yourTargetTable

Open in new window

0
 
LVL 2

Author Comment

by:brgdotnet
ID: 40495516
So awesome,

Thanks.
0
 
LVL 13

Expert Comment

by:Koen Van Wielink
ID: 40495519
Most welcome.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
When trying to connect from SSMS v17.x to a SQL Server Integration Services 2016 instance or previous version, you get the error “Connecting to the Integration Services service on the computer failed with the following error: 'The specified service …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question