Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL Remove first two characters of all fields

I have some data that looks like this:

C:10
R:200
N/A
E:3
N/A
N:77

I'm trying to remove the first two characters for each row, and skip the rows with N/A I've been trying to figure out how to do this with SUBSTRING but have had no luck.

UPDATE d1
SET d1_val = SUBSTRING(d1_val, 1, LENGTH(d1_val)2)
like image 793
Norse Avatar asked Apr 30 '12 19:04

Norse


Video Answer


1 Answers

Try

UPDATE d1
SET d1_val = SUBSTRING(d1_val, 3)
WHERE d1_val <> 'N/A'
like image 146
Kevin DiTraglia Avatar answered Oct 19 '22 15:10

Kevin DiTraglia