SQL INNER JOIN update does NOT duplicate rows

I have an update request that has an internal connection. I expect this query to return two columns due to a join, but QUERY seems to occupy only the first row and uses this to update the data, ignoring the rest.

Here is my update team

UPDATE [mamd]
    SET [Brand_EL] = IIF(CHARINDEX('ELECT', UPPER([mml].[Brand_Desc])) > 0, 'YES', [Brand_EL])
    FROM [mamd] [m]
         INNER JOIN [ior] [ir] ON [ir].[CLIENT_CUSTOMER_ID] = [m].[CustomerId] COLLATE Latin1_General_CI_AS
         INNER JOIN [maslist] [mml] ON [mml].[Model] = [ir].[MODEL] COLLATE Latin1_General_CI_AS

If I make a similar choice

SELECT [ir].[CLIENT_CUSTOMER_ID], IIF(CHARINDEX('ELECT', UPPER([mml].[Brand_Desc])) > 0, 'YES', [Brand_EL])
    FROM [mamd] [m]
         INNER JOIN [ior] [ir] ON [ir].[CLIENT_CUSTOMER_ID] = [m].[CustomerId] COLLATE Latin1_General_CI_AS
         INNER JOIN [maslist] [mml] ON [mml].[Model] = [ir].[MODEL] COLLATE Latin1_General_CI_AS

I get the following data:

CLIENT_CUSTOMER_ID | Brand_EL
-------------------+----------
980872             | NO 
980872             | YES

The reason I think she takes only one record is because

  • NEVER changes to "YES"
  • When I run the update command, it says only one line updated, although it had to go through two

, , , [mamd] ; . , , ? , ?

UPDATE

,

, Gordons Advice . , , , "", , . , , MAX. , "" . , NO NULL. .

+4
1

, :

FROM . UPDATE: undefined, FROM, , , , UPDATE . , UPDATE script, 1 FROM UPDATE; undefined, 1 2.

, , , update. , . , , .

+4

All Articles