merge two tables

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a xls spread sheet of email addresses that I imported into a table
I'll call 'tblOutSideEmail'. The primary field is employee number. I would
like to update the changes in this table (email field) to my orginal table
called 'tblLoginRequired'. I have tried using an udate query with
[tblOutSideEmail].[emailAddress] but I keep getting an error. I thought it
was suppose to be simple! hehe

What am I doing wrong? Can I not merge the two together with only the
changes made in the tblOutsideEmail?

Table 1
tblLoginRequired

Fields
empNumber
emailAddress

Table 2
tblOutSideEmail

Fields
empNumber
OutSideEmail
 
I have a xls spread sheet of email addresses that I imported into a table
I'll call 'tblOutSideEmail'. The primary field is employee number. I would
like to update the changes in this table (email field) to my orginal table
called 'tblLoginRequired'. I have tried using an udate query with
[tblOutSideEmail].[emailAddress] but I keep getting an error. I thought it
was suppose to be simple! hehe

What am I doing wrong?

I don't know, because you don't say what you're doing! When you ask
advice on a Query, please open the query in SQL view and post the SQL
text here; and if you get an error message, it is important to...
ummm... tell us what the error message SAYS. We can't see your screen!
Can I not merge the two together with only the
changes made in the tblOutsideEmail?

Table 1
tblLoginRequired

Fields
empNumber
emailAddress

Table 2
tblOutSideEmail

Fields
empNumber
OutSideEmail

I would EXPECT the following query to work, given reasonable structure
(e.g. a Primary Key on EmpNumber in both tables):

UPDATE tblLoginRequired
INNER JOIN tblOutSideEmail
ON tblOutsideEmail.EmpNumber = tblLoginRequired.EmpNumber
SET tblLoginRequired.EMailAddress = tblOutsideEmail.OutSideEmail;

Note that this will ERASE any existing EMailAddress in
tblLoginRequired, replacing it with the OutSideEmail value. If you
only want to insert addresses if there is none in tblLoginRequired
already, use a criterion:

UPDATE tblLoginRequired
INNER JOIN tblOutSideEmail
ON tblOutsideEmail.EmpNumber = tblLoginRequired.EmpNumber
SET tblLoginRequired.EMailAddress = tblOutsideEmail.OutSideEmail
WHERE tblLoginRequired.EMailAddress IS NULL;


John W. Vinson[MVP]
 
Back
Top