I tried a couple of things but it deleted the complete content from the column.
Here's what I want to do - A particular table [abc_tablename] in my MySQL database has a column [xyz_columnname] that has a lot of email IDs (more than 5000) and I want them to replace all the email IDs with a text [email ID removed]
I used the following query for SELECT:
SELECT *
FROM abc_tablename
WHERE xyz_columnname LIKE '%@%'
How do I perform the replace function in this case? Can you help me with the query for the same. I tried this but it removed all the data from xyz_columnname
UPDATE abc_tablename
SET xyz_columnname = REPLACE ( xyz_columnname, LIKE ''%@%'', '**email ID removed**');
I'm using PHPMyAdmin to run these queries. Also, do note that xyz_columnname has a lot of text and numeric content along with the email ID.
xyz_columnnamejust an email address and nothing else? Or is it an email address among a bunch of other text likeblah blah [email protected] blahand you only want to replace the email in that text? If that is the case, you would likely need to use a regular expression to perform a replace. Mysql doesn't have a built in regexp replace function so you would need to use something like php and update it or define a udf version of regexp_replace (there are several out there).%@%, fix them and update the rows one at a time or implement one of the many regexp_replace user defined functions within mysql use that. The latter would likely be more performant, but if you are doing this as a one off thing, just brute force it the easier way with php and in the future, fix it before insert.