simonp Posted December 4, 2007 Share Posted December 4, 2007 Hi, Is it possible to search and replace data in a table? Ie - change all instances of 0205 to 01205 in a telephone number field. Thanks Simon Quote Link to comment https://forums.phpfreaks.com/topic/80136-solved-search-and-replace-in-mysql-data/ Share on other sites More sharing options...
trq Posted December 4, 2007 Share Posted December 4, 2007 UPDATE tbl SET fld = REPLACE(fld,'0205','01205'); Quote Link to comment https://forums.phpfreaks.com/topic/80136-solved-search-and-replace-in-mysql-data/#findComment-406109 Share on other sites More sharing options...
simonp Posted December 4, 2007 Author Share Posted December 4, 2007 Thanks thorpe (and apologies for posting in the wrong forum!) Will that work for part of a field though? ie - will it change 0205 457541 0205 878469 0205 145785 to: 01205 457541 01205 878469 01205 145785 Cheers Simon Quote Link to comment https://forums.phpfreaks.com/topic/80136-solved-search-and-replace-in-mysql-data/#findComment-406116 Share on other sites More sharing options...
fenway Posted December 4, 2007 Share Posted December 4, 2007 It will replace all instances of this matching string. Quote Link to comment https://forums.phpfreaks.com/topic/80136-solved-search-and-replace-in-mysql-data/#findComment-406130 Share on other sites More sharing options...
simonp Posted December 4, 2007 Author Share Posted December 4, 2007 brilliant - thanks guys. Simon Quote Link to comment https://forums.phpfreaks.com/topic/80136-solved-search-and-replace-in-mysql-data/#findComment-406136 Share on other sites More sharing options...
fenway Posted December 4, 2007 Share Posted December 4, 2007 Just be careful that it doesn't match part of a larger string by accident. Quote Link to comment https://forums.phpfreaks.com/topic/80136-solved-search-and-replace-in-mysql-data/#findComment-406174 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.