Reputation: 3
I have a column that just has 4 numbers and I want to remove the first. I Run a update query I found on here but it says no columns affected.
UPDATE mytable
SET mycol = TRIM(LEADING '[0-9]' FROM mycol)
I don't get an error when I run it just does not do anything.
Upvotes: 0
Views: 883
Reputation: 6024
You can test mycol
has digit with mycol RLIKE '^[0-9]'
, remove with SUBSTRING(mycol, 2)
:
UPDATE mytable
SET mycol = SUBSTRING(mycol, 2)
WHERE mycol RLIKE '^[0-9]'
Documentation:
Upvotes: 1
Reputation: 4081
Try:
UPDATE `tablename`
SET `columnname` =
TRIM(LEADING 'THE CHARACTER YOU WANT TO REMOVE, eg: 1' FROM `columnname`);
Upvotes: 1