Question;
In the below MySQL query the inner query which produces the list of ConnectionIDs returns 34 ConnectionIDs. When I then run the two queries together as an update the query result indicated that only 14 rows were affected. Is my understanding of how the UPDATE function incorrect?
Notes;
I am trying to update my database so that the DefaultUserType in the Partners table is equal to the RoleID in the connections table for any given connection where the Connections.PartnerID is equal to the Partners.PartnerID.
Query;
UPDATE Connections
LEFT JOIN Partners
ON Connections.PartnerID = Partners.PartnerID
SET Connections.RoleID = Partners.DefaultUserType
WHERE
ConnectionID IN(
SELECT
sub_qu_1.ConnectionID
FROM
(
SELECT DISTINCT
Connections.ConnectionID,
Connections.MemberID,
Connections.FriendID,
Connections.RoleID,
Partners.DefaultUserType,
IF(Connections.RoleID = Partners.DefaultUserType,0,1)AS not_equal
FROM
Connections
LEFT JOIN Contacts ON Connections.FriendID = Contacts.EEID
LEFT JOIN Partners ON Contacts.PartnerID = Partners.PartnerID
WHERE
Partners.DefaultUserType NOT IN (28,29,30)
)AS sub_qu_1
WHERE
not_equal = 1
AND DefaultUserType IS NOT NULL
)