views:

128

answers:

1

Morning,

I'm storing documents informations (Word, excel, ...) in a MySQL database. I have a column "size" where i store the filesize in bytes like 582656, 136260, 383266... But when i order by size, results are a little bit disorder. What type of mysql field should i use ? I've tried VARCHAR and INT, same result.

Regards, Emmanuel

A: 

VARCHAR will definitely give you the incorrect results as is will sort from left to right.

eg, VARCHAR sorted will place 12 before 2, as the first 1 in 12 is less than 2.

But INT should give you what you require.

Have a look at a couple of types here

Numeric Types

astander
Your are right. It's works. I'm using a view to display my data and forget to change the colum type in the view...Thanks !
Maïs