Welcome Guest, Not a member yet? Register   Sign In
Database INSERT changes NULL value to empty string
#8

(This post was last modified: 03-04-2016, 01:52 PM by Narf.)

(03-04-2016, 01:07 PM)webmachine Wrote: Not a problem here. The issue is with foreign key id's that don't have to be entered. I'm finding that even if I set the default to NULL, a 0 is entered, so I decided to stick with 0.

Now that you say this, I think there's another side to it - unless I'm mistaken, you cannot have a foreign key reference to a NULL "value".

I'm quoting that word on purpose, because NULL is in fact not a value, but a token for lack of value and therefore a foreign key doesn't make sense - a reference can't point to nothing. This is not limited to databases, but there are a lot of other instances in DB programming where it becomes obvious, like COUNT(field_name) ignoring rows where field_name is NULL.
Reply


Messages In This Thread
RE: Database INSERT changes NULL value to empty string - by Narf - 03-04-2016, 01:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB