Jump to content

ORDER BY: order varchar (interger data, 0 fields) like int...


leeming

Recommended Posts

ok in my databse field, 0 is an option. and since int doesnt save 0, and have to use varchar instead...

this is my problem...

im wanting to order the table by this field, but some thing like the following outputs

[quote]1
10
11
2
3
35
5[/quote]

instead of the ovious...

is there a command when selecting the field, to like

[code]"SELECT table.field AS table.field(INT) [/code]
See the [url=http://dev.mysql.com/doc/refman/5.1/en/cast-functions.html]cast functions[/url].  I haven't tried it, but something like "SELECT CAST(table.field AS UNSIGNED) AS IntColumn ... ORDER BY IntColumn" might work.

And what do you mean by "int doesnt save 0"?  You can have a zero in an integer column.  If you need to differentiate between "no value" and "zero," use NULL.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.