Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 01-10-2003, 08:10 PM   #1 (permalink)
Henry
Registered User
 
Join Date: Dec 2002
Location: Chicago
Posts: 13
Henry is on a distinguished road
Integers columns

Is it possible to have Integer columns in a table, which do not enter a zero into the field if it is left blank?

If so, can this be done with a particular Attribute or an Extra?

I have the Default set to NULL on a series of Int columns receiving data from a survey, but I still get zeros when no choices are made to the corresponding questions in the form once it is submitted.
Henry is offline   Reply With Quote
Old 01-10-2003, 08:22 PM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,490
sde is on a distinguished road
if you are using phpmyadmin, it could be because those colums were not set null at first, and it automatically puts a '0' in there.

then when you make each field NULL, then it retains the default entry that was previously entered.

you will have to go back and type NULL as your default for that table.

now if you're not using phpadmin, .. then yes, it is possible .. the mysql code for adding a field to a table would be something like this:
Code:
ALTER TABLE 'db'.'table' ADD 'some_field' INT DEFAULT NULL;
sde is offline   Reply With Quote
Old 01-11-2003, 07:51 AM   #3 (permalink)
Henry
Registered User
 
Join Date: Dec 2002
Location: Chicago
Posts: 13
Henry is on a distinguished road
phpmyadmin

I am using phpmyadmin. When I set up the table, I created the integer columns by typing 'field name' Int, and the table was created with null-yes, default NULL for all of the columns, including the integer ones. I'm not having any problems wiht any of the other columns, when they are left blank on the form, there is nothing entered into the column in the table. The default settings are the same for all of the comumns in the table, but the integer columns are defaulting at zero, in spite of the DEFAULT setting.

Should I just change these columns to enum with the five possible numbers set as the values? It seems like the easiest solution, I just wanted to makle sure that it was the only quick one.

Thanks
Henry is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 04:30 PM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting