I have a table called `inidviduals` that have 10,000 records in the table and I want the query to change only the specific ones.
Table Structure is:
CREATE TABLE individuals (
`ID` int(10) unsigned NOT NULL default '0',
`Last_Name` varchar(255),
`Soundex_Code` varchar(10),
PRIMARY KEY (`ID`)
);
Current query is:
UPDATE individuals
SET Soundex_Code = CASE WHEN Last_Name = 'Aaron' THEN 'A650'
WHEN Last_Name = 'Abercrombie' THEN 'A162'
WHEN Last_Name = 'Aberlenc' THEN 'A164'
ELSE '' END;
Above query modifies ALL records, because of ELSE ''.
How can I optimize this to update only those records which matches in one query?