0

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

2

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.

6
  • i thought that already, in future i want change number to string like... pro1, pro2 like that..so i cant change datatype Sep 12 '14 at 8:59
  • 1
    @Prashant if you want your data to behave like numbers (i.e. show correctly maximum and minimum, do increments/decrements), use a number datatype, as this answer suggests. Not chars. Sep 12 '14 at 9:06
  • @ypercube : check my edited question. Sep 12 '14 at 9:10
  • It doesn't make any more sense. Don't do that, not now, not in the future. If your requirements are to store numbers as strings, change them. They are not sane requirements. I'm sure the underneath problem can be solved in some other manner. Sep 12 '14 at 9:17
  • @ypercube i did, but problem not solved Sep 12 '14 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.