I am trying to add new column and wants update its value based on some condition but it does not allow me to do that it says "You can't specify target table 'a' for update in FROM clause"
Any Idea, how to do that?
mysql
ALTER TABLE test ADD COLUMN step1_pincode VARCHAR(20);
UPDATE test a SET a.step1_pincode =
(
SELECT CASE WHEN b.RetailerPincode IS NOT NULL
THEN RetailerPincode
ELSE b.StorePartyPincode
END AS step1_pincode1
FROM test b
);