n8w Posted April 7, 2012 Share Posted April 7, 2012 I have a column that has values like record 1 = bob,nancy, sally record 2 = bob,nancy record 3 = nancy, sally What I would like to do is replace all instances of nancy with betty so all my records would look like this record 1 = bob,betty, sally record 2 = bob,betty record 3 = betty, sally can someone please point me in the right direction of what my sql statement should look like? Thanks Link to comment https://forums.phpfreaks.com/topic/260508-search-and-replace-using-a-sql-statement/ Share on other sites More sharing options...
awjudd Posted April 7, 2012 Share Posted April 7, 2012 You can use MySQL's REPLACE function http://dev.mysql.com/doc/refman/5.0/en/replace.html Either do it in a SELECT statement (non-permanent) or an UPDATE statement (changing the actual values in the table). ~awjudd Link to comment https://forums.phpfreaks.com/topic/260508-search-and-replace-using-a-sql-statement/#findComment-1335193 Share on other sites More sharing options...
n8w Posted April 8, 2012 Author Share Posted April 8, 2012 Thanks .. this worked great update client_table set company_name = replace(company_name, ‘Old Company’, ‘New Company’) Link to comment https://forums.phpfreaks.com/topic/260508-search-and-replace-using-a-sql-statement/#findComment-1335410 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.