INSERT INTO Table

J

Joe K.

Please help me create SQL statement.

I would like to INSERT values INTO MemberKey field for tblUSER_PA table that
correspond to the same value MemberKey field from the SU_People table.
Both tblUSER_PA and SU_People tables have same User_Cd field which they can
be joined on.

Listed below is my start at the SQL statement to complete this task.

Please help me complete this task.

Thanks,


INSERT INTO tblUSER_PA.[MemberKey]
SELECT [SU_People].[MemberKey]
FROM [SU_People] INNER JOIN tblUSER_PA ON [SU_People].[User_Cd] =
tblUSER_PA.[UserCd]
WITH OWNERACCESS OPTION;
 
J

John W. Vinson

Please help me create SQL statement.

I would like to INSERT values INTO MemberKey field for tblUSER_PA table that
correspond to the same value MemberKey field from the SU_People table.
Both tblUSER_PA and SU_People tables have same User_Cd field which they can
be joined on.

Listed below is my start at the SQL statement to complete this task.

Please help me complete this task.

Thanks,


INSERT INTO tblUSER_PA.[MemberKey]
SELECT [SU_People].[MemberKey]
FROM [SU_People] INNER JOIN tblUSER_PA ON [SU_People].[User_Cd] =
tblUSER_PA.[UserCd]
WITH OWNERACCESS OPTION;

If you want to *ADD NEW RECORDS* to the table where none existed before, you
want an INSERT INTO query. However, it sounds like you want to update existing
records to change the value of the MemberKey field... right?

If so,

UPDATE tblUSER_PA INNER JOIN SU_People
ON [SU_People].[User_Cd] = tblUSER_PA.[UserCd]
SET tblUSER_PA.MemberKey = SU_People.MemberKey;

I'm a bit queasy about the need to do this - if the UserCD (or User_CD) field
uniquely determines the MemberKey then one of the fields is redundant in one
of the tables, and probably should not exist!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top