MySQL – Column Value Not Incrementing After 10

functionsMySQLsequence

I tried below 2 codes…. showing same error

1.SELECT columnname FROM tablename ORDER BY columnname DESC LIMIT 1

  1. SELECT MAX(columnname ) AS max FROM tablename

I am trying to increment value of column.(++string) It worked properly till 10. After 10 it is not increment.

then i checked manually, then i get result 9.

Result Got – 1 2 3 4 5 6 7 8 9 10 10 10 10

Result Required – 1 2 3 4 5 6 7 8 9 10 11 12

I think database count 10 as 1. i dont know why?

In future i want change number to string like… pro1, pro2 like that..so that i dont want to change datatype

Best Answer

I think you have your column data-type on non numeric format. if your data type is CHAR (or VARCHAR) type it would select 9 as your max number.

If you change your datatype for the column to INT, your problem should be resolved.