jarv Posted December 6, 2010 Share Posted December 6, 2010 hi, in my database I have a rsTel datafield so most phone numbers read something like this: 0180-320-1401 I would like to remove the '-' and put a space after the first 5 characters is there an UPDATE SQL statement I can write or PHP code which will update ALL my phone numbers in my database? Link to comment https://forums.phpfreaks.com/topic/220816-need-to-remove-all-from-rstel-datafield-in-database/ Share on other sites More sharing options...
AbraCadaver Posted December 6, 2010 Share Posted December 6, 2010 hi, in my database I have a rsTel datafield so most phone numbers read something like this: 0180-320-1401 I would like to remove the '-' and put a space after the first 5 characters is there an UPDATE SQL statement I can write or PHP code which will update ALL my phone numbers in my database? I wouldn't worry about the space. This will replace the - though: UPDATE table_name SET datafield = REPLACE(datafield, '-', '') If you must have the space, then look at the string functions: http://dev.mysql.com/doc/refman/5.0/en/string-functions.html. Probably a combination of LEFT, LENGTH, RIGHT and CONCAT/CONCAT_WS. Should be a fun learning exercise :-) Link to comment https://forums.phpfreaks.com/topic/220816-need-to-remove-all-from-rstel-datafield-in-database/#findComment-1143627 Share on other sites More sharing options...
AbraCadaver Posted December 6, 2010 Share Posted December 6, 2010 Or just SUBSTRING and CONCAT_WS. Link to comment https://forums.phpfreaks.com/topic/220816-need-to-remove-all-from-rstel-datafield-in-database/#findComment-1143633 Share on other sites More sharing options...
jarv Posted December 7, 2010 Author Share Posted December 7, 2010 Thankyou very much indeed AbraCadaver!!!! x Link to comment https://forums.phpfreaks.com/topic/220816-need-to-remove-all-from-rstel-datafield-in-database/#findComment-1144024 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.