leeming Posted July 6, 2006 Share Posted July 6, 2006 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]1101123355[/quote]instead of the ovious...is there a command when selecting the field, to like[code]"SELECT table.field AS table.field(INT) [/code] Quote Link to comment Share on other sites More sharing options...
Wildbug Posted July 6, 2006 Share Posted July 6, 2006 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. Quote Link to comment Share on other sites More sharing options...
leeming Posted July 6, 2006 Author Share Posted July 6, 2006 ok thanks, i did come across the CAST function slightly after i posted this... but i just didnt understand it...as for the '0' in INT, i didnt know that.. always been told to us it as varchar Quote Link to comment Share on other sites More sharing options...
fenway Posted July 6, 2006 Share Posted July 6, 2006 Besides, why are you storing numbers in a varchar field? And "+0" works wonders too, and doesn't require 4+. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.