2

phpmyadmin

column name - level
current values - lev1 lev2 lev3 lev4...
wanted values - 1 2 3 4 ...

According to accepted and highly voted answer here, code should be like this:

UPDATE tmatria SET level = replace(level, 'lev', '');

But entering the above code inside phpmyadmin sql window I have a lot of errors.

What is the correct way to do this ?

Community
  • 1
  • 1
qadenza
  • 9,025
  • 18
  • 73
  • 126

1 Answers1

1

If the value have alway the same prefix You can also use

UPDATE tmatria 
SET level = substr(level, 4, 100);
ScaisEdge
  • 131,976
  • 10
  • 91
  • 107
  • Please provide explanation to your answer. – Milan Gupta Jul 31 '16 at 14:16
  • @MilanGupta .. is simple do the fact the OP have problem using the update with repalce .. i suggest an alternative .. in this case having a fixed prefix a solution is set the column level wth the right substr of the string.... (4,100) ) mean the substring starting form the forth character to 100 char (100 is an high value for take all the char) .. hope is clear ..and useful for you – ScaisEdge Jul 31 '16 at 14:25