mysql order negative number

In a table (chronological) if you have dates stored as text you could have problem to order your data.

I.g. you coud have this (wrong) order:

-13.600.000.000, -13.700.000.000,-4.600.000.000

To get the right order you can try with

cast(data as int)

Where “data” is the column of data (as the above values). In this way you will get the correct order:

-13.700.000.000, -13.600.000.000,-4.600.000.000

Lascia un commento

Il tuo indirizzo email non sarĂ  pubblicato. I campi obbligatori sono contrassegnati *