Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

INSERTing NULL versus '0' in numeric fields

Status
Not open for further replies.

rhyno2k

IS-IT--Management
Jun 9, 2001
222
US
Hi,


My PHP application does a mass INSERT of about 3 dozen fields, many of
them numeric. After I run the INSERT, however, MySQL places a bunch
of "0"s (zeroes) in every numeric field, even if a null value was
passed.

I don't want to convert these fields to VARCHARs... so can I:
- force a NULL insert
- change default NULL insert behavior (i.e. don't put a 0 in!)
or
- easily run a post-INSERT one-line SQL statement to change all "0"
field values to null?

(MySQL 4.1.7)


Thanks,
--RHYNO
 
if you want NULL in the column when you insert a NULL, then the column needs to be defined as NULL

you've probably defined it as NOT NULL DEFAULT 0



r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top