Reputation: 825
I'm writing a table for the database, which contains a column for person's name, another for total holiday days and another for used holiday days. My question is.... the person might not used any days yet, so this value can be 0. Is it right then to set it to NULL? I'm a bit confused because now, I have added a new person, and I've put VALUES('Ana','170','0'). So I built the system to add a new person, but because they all start with 0 holiday used, I just did the query for the person's name, but then if I have a look on the table, on the person I've added through mysql directly it says used holiday 0, but in the one I add with the form, it says NULL. Does it means the same?
Thank you
Upvotes: 0
Views: 1275
Reputation: 71
NULL is a special value that represents no value. Here are basic rules about NULL values: NULL presents no value. NULL is not the same as an empty string ''. NULL is not the same as a zero value 0. NULL can be used as any data type. NULL should not be used in any comparison options. NULL has its own equality operator "IS". NULL has its own not-equality operator "IS NOT". The tutorial exercise shows you some interesting examples: SELECT 0 IS NULL FROM DUAL; 0
SELECT 0 IS NOT NULL FROM DUAL; 1
SELECT '' IS NULL FROM DUAL; 0
SELECT '' IS NOT NULL FROM DUAL; 1
SELECT NULL IS NULL FROM DUAL; 1
SELECT NULL IS NOT NULL FROM DUAL; 0
http://dba.fyicenter.com/faq/mysql/What-IS-NULL-Value.html
Upvotes: 3