Welcome to WebmasterWorld Guest from

Forum Moderators: open

Message Too Old, No Replies

db field default value: none vs null



2:04 pm on Jun 22, 2011 (gmt 0)

Hi there,

I just have one little question. I'm using phpMyAdmin to set up a database and I was wondering, what is the difference between setting a field's default value to none and setting it to null? what are the benefits/disadvantages of each? and how do they relate to php? (for example if i'm pulling records from the db and testing the returned values with isset, what does null vs none return?) if there is a comprehensive answer to this question out there somewhere already, i missed it, so here i am asking :-)


2:41 pm on Jun 22, 2011 (gmt 0)

WebmasterWorld Senior Member demaestro is a WebmasterWorld Top Contributor of All Time 10+ Year Member

I don't think 'none' is a value you can give. Unless it is the string 'none'.

If you by 'none' you mean an empty string, then there are differences, but they are subtle.

The best way to explain it is like this, if you insert a row into your table and you don't specify a value for a column then it's value will be null.

Null works for all data types, boolean, string, integer and so on. Where as an empty string won't work in an integer field, and 0 won't work in a string field, although '0' would.

Typically you will see a lot of queries checking for both.

select * from table where StrField is not null and != ''


select * from table where IntField is not null and != 0

I wouldn't say one has an advantage over another but I would say be consistent throughout your application.

Featured Threads

Hot Threads This Week

Hot Threads This Month