Mrkay Posted October 25, 2013 Share Posted October 25, 2013 Hi and thanks in advance. Apologies but I'm a newbie at this. I've got a field in a MySql (Place_id) table called Pic. Most of the data in that field is in the form #1234 but some are in the format 1234. What I want to do is strip out the # part of the data in every record of that field in the table that contains it. Can anyone help me with the sql please. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/283269-field-shorten-in-phpmyadmin/ Share on other sites More sharing options...
Solution PravinS Posted October 25, 2013 Solution Share Posted October 25, 2013 (edited) use MySQL replace function in query like this UPDATE Pic SET Place_id = REPLACE(Place_id, '#', '') also do take table backup before doing mass update Edited October 25, 2013 by PravinS Quote Link to comment https://forums.phpfreaks.com/topic/283269-field-shorten-in-phpmyadmin/#findComment-1455382 Share on other sites More sharing options...
Mrkay Posted October 25, 2013 Author Share Posted October 25, 2013 I get an error - this is what I did and the response. ErrorSQL query: SELECT * FROM `Pic` UPDATE Pic SET Place_id = REPLACE( Place_id, '#', '' ) LIMIT 0 ,30 MySQL said: #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'UPDATE Pic SET Place_id = REPLACE(Place_id, '#', '')LIMIT 0, 30' at line 2 Quote Link to comment https://forums.phpfreaks.com/topic/283269-field-shorten-in-phpmyadmin/#findComment-1455388 Share on other sites More sharing options...
Mrkay Posted October 25, 2013 Author Share Posted October 25, 2013 I've sorted it - didn't need the -SELECT * FROM `Pic` Doh. Thank you very much!! Quote Link to comment https://forums.phpfreaks.com/topic/283269-field-shorten-in-phpmyadmin/#findComment-1455392 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.