Results 1 to 3 of 3
Jun 13, 2012, 10:13 #1
Must I use an integer column type instead of a varchar column for numbers?
I am working on a MySQL database table for baseball game scores.
Does anybody know why I need to use one of the integer column types to store numbers?
If I do a SELECT clause and apply the gettype() function to numbers extracted from an integer column types they come out as type "string" - not type "integer."
I am trying to get an integer column to have a default value of empty. However, the table automatically inserts a "0" in an empty column. It displays on the page as a "0" when there should be a blank space there (before the games are played it needs to be an empty space since there's not yet a score).
If I use a varchar column type it will default to an empty cell. If I extract the number from the varchar column type using a select function is also comes out as type "string."
Basically, varchar does what I need with a number. The integer column type does not.
I am trying to figure out if I use varchar column types for the numerical scores, instead of the integer type, will it cause problems later on?
I would appreciate any information that someone might have.
Jun 13, 2012, 10:22 #2
- Join Date
- Jul 2002
- Toronto, Canada
- 53 Post(s)
- 2 Thread(s)
presumably it's php, in which case you should ask that question in the php forum
in summary, don't use VARCHAR, use SMALLINT (unless your scores can exceed 32768, then use INTEGER)
Jun 13, 2012, 16:33 #3
Thanks for responding to my question. NULL is what I needed to know. I set the column default setting to NULL and it eliminated the zeros.