Tomislav Mladenovski Tomislav Mladenovski - 5 months ago 13
SQL Question

SQL Insert/update field with text before a character

I am using MySql and one of my tables, User_tb, has a column, user_email, where I store users' email addresses. I am relatively new to SQL, but I need to insert 'Sponsored' before the @ from the email address.

Example, dummyuser@gmail.com => dummyuserSponsored@gmail.com .

All my research points me to using substr however I am not exactly sure how to actually executed on it. Any help is appreciated :)

Answer
update User_tb set user_email = replace(user_email, '@', 'Sponsored@')

http://dev.mysql.com/doc/refman/5.7/en/string-functions.html#function_replace