GET 24/7 LIVE HELP NOW

Announcement

Announcement Module
Collapse
No announcement yet.

MySQL: Replacing the first 0 with 44

Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MySQL: Replacing the first 0 with 44

    I have a problem I hope someone can help me with. I have about 2000 records that I need to change permentantly in a MySQL database -mobile numbers that start with 0 need to be changed so that they start with 44. I have been looking on every forum I can find but cannot find an answer. If anyone has any suggestions, I would be very very grateful. I am quite new to MySQL so go easy on me!

    Cheers,

  • #2
    Hi,

    I am not sure I understand your question correctly, but I think you need something like:


    UPDATE numbersSET number = CONCAT('44', SUBSTRING(number,2))WHERE 1 AND number LIKE '0%'



    If you do this query frequently, it would perform better with an index on the number column.

    Comment


    • #3
      Thank you so much - the code worked brilliantly!

      Comment

      Working...
      X