Skip to content
Advertisement

How to make a multiple update on mysql with string replace with value of another column

Hello i’m new in mysql and i have to run a multiple update on my table. I have 700 records in the table and i have to update them all this way:

table example : store_id: 1 store_email: storename@gmail.com

for single update i use

JavaScript

i need to update all the emails and replace their name with their id, so it would be like this:

storename@gmail.com –> 1@gmail.com

storename@gmail.com –> 2@gmail.com

storename@gmail.com –> 3@gmail.com

those numers have to be the ID for each store.

Hope you can understand

Thanks for help.

P.S. i need to run it on magento 2

Advertisement

Answer

you can use CONCAT() and RIGHT() function for manipulating strings like this:

JavaScript

The RIGHT('string', n) function extracts n characters (storemail = 9 chars in your case) from a string (starting from right).

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement