Target row is being updated by multiple source rows in an Update statement

Database
Enthusiast

Target row is being updated by multiple source rows in an Update statement

I have an update statement directly referencing one table and a second one through a SELECT statement.

That second table (CONTACT_TEMP) is created to hold no duplicates  based on the EMAIL field as a primary index. So I'm confused as to why TD is giving me error 7547: Target row is being updated by multiple source rows in an UPDATE statement

Here's the statement:

 UPDATE tgt
 FROM DATA.CONTACTS tgt, (
   SELECT  
   ID
   ,Email
   ,Last
   ,First
   FROM CONTACT_TEMP
   WHERE  upper(EMAIL) IN (
     SELECT upper(Email_Address)
     FROM DATA.CONTACTS
  WHERE BPP_IND = '1'
   )
   )  ppage  --Grabs one row for each email since there are duplicates
 SET
      BPP_User_Id = ppage.ID
  ,Email_Address = ppage.Email
  ,Last_name = ppage.Last
  ,First_name = ppage.First
 ;

Any ideas as to what's happening?

Tags (1)
1 REPLY
Senior Apprentice

Re: Target row is being updated by multiple source rows in an Update statement

The WHERE-condition is missing:

...
SET
BPP_User_Id = ppage.ID
,Email_Address = ppage.Email
,Last_name = ppage.Last
,First_name = ppage.First
WHERE tgt.Email = ppage.Email;