If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Access > INSERT from two tables

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-09-12, 16:42
DavidKi DavidKi is offline
Registered User
 
Join Date: Jan 2012
Posts: 7
Question INSERT from two tables

Good evening,

I'm trying to insert Fiscal Year from one table and unique ID from another table joined by Employee Number. Anyone know how to make it work?
Reply With Quote
  #2 (permalink)  
Old 01-09-12, 17:59
Sinndho Sinndho is offline
Registered User
 
Join Date: Mar 2009
Posts: 3,446
Like this:
Code:
INSERT INTO DestinationTable ( [Fiscal Year], [unique ID] )
SELECT SourceTable1.[Fiscal Year], SourceTable2.[unique ID] 
FROM SourceTable1 INNER JOIN 
     SourceTable2 ON SourceTable1.[Employee Number] = SourceTable2.[Employee Number];
Use a LEFT JOIN if you want to keep Null values for the rows (if any) where there is no match for [Employee Number] between both table.

Note: You should refrain from using spaces (or other non-alphanumeric characters as well as reserved words) in the names and replace them with an underscore:
"Fiscal_Year" instead of "Fiscal Year"
__________________
Have a nice day!
Reply With Quote
  #3 (permalink)  
Old 01-11-12, 14:03
DavidKi DavidKi is offline
Registered User
 
Join Date: Jan 2012
Posts: 7
INNER JOIN works amazing.

Thanks Sinndho!
Reply With Quote
  #4 (permalink)  
Old 01-11-12, 14:06
Sinndho Sinndho is offline
Registered User
 
Join Date: Mar 2009
Posts: 3,446
You're welcome!
__________________
Have a nice day!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On