I read a number of posts and replies about this error, but all the replies give specific answers to the specific question. Can someone explain what the issue is, and how to overcome it in general, so that I don't have to post every problem query here.
This is the code for my procedure
CREATE PROCEDURE `sp_FixEntityNames`(IN `importId` BIGINT UNSIGNED)
BEGIN
UPDATE ImportedSymbols s
JOIN ExchangeMappings m ON s.ExchangeMappingId = m.ExchangeMappingId
SET s.EntityName =
(
SELECT s1.EntityName
FROM ImportedSymbols s1
JOIN ExchangeMappings m1 ON s1.ExchangeMappingId = m1.ExchangeMappingId
WHERE
s1.ImportId = importId
AND
s1.Symbol = s.Symbol
AND
s1.Suffix = NULL
AND
s1.MarketId = NULL
AND
s1.SecurityTypeId = 1
AND
m1.NamespaceId = m.NamespaceId
)
WHERE
s.ImportId = importId
AND
(
s.Suffix != NULL
OR
s.MarketId != NULL
OR
s.SecurityTypeId != 1
);
END