MySQL query bulk update

Faizan Khan
Feb 3, 2022

--

Had to update domain part of emails in users table to junk domains for testing. Previously it was done with a for loop in php. Execution time for 9313 rows was around 59.911 Seconds

Same task was done via mysql query in 0.03 seconds for 93913 records.

UPDATE users SET email = CONCAT(LEFT(email, INSTR(email, ‘@’)-1), ‘_’,id, ‘@xyz.com’)

--

--

Faizan Khan
Faizan Khan

Written by Faizan Khan

Computer Engineer, Full Stack, Tech, Travel

No responses yet