-1

We are currently storing a load of customer mobile numbers, however most of them are missing the leading 0.

How can I add a 0 in SQL to the front of all mobile numbers where the first digit equals 7?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
joehelsing
  • 83
  • 7

2 Answers2

4

You may use LIKE here:

UPDATE yourTable
SET mobile = '0' + mobile
WHERE mobile LIKE '7%';
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
0

You can write a concat statement

update table
set yourcolumn = CONCAT('0', yourcolumn)
where yourcolumn like '7%'
ArchAngelPwn
  • 2,891
  • 1
  • 4
  • 17