Welcome to WebmasterWorld Guest from 184.108.40.206 , register , free tools , login , search , pro membership , help , library , announcements , recent posts , open posts Pubcon Platinum Sponsor 2014
What is better as a default value: NULL or ''? In the MySQL table... GreenLeaf
I would like to collect some statistical data and then make some reports on it. I'm creating tables for this task and i'm not sure what is better for filling default values: NULL or ''. What is optimal for storage purposes and for further reports creation? Thanks in advance.
If you're willing to make the slight extra effort to use & handle NULL, it is a better choice for a not-present value because it provides you with additional information about why the field is blank.
Often NULL is used to mean "A value isn't available" and the empty-string '' means "There is a value, and it is empty." Subtle difference, but often critical for things like reports.
I remember to have problems with NULL in UNION statements like
select something, null, ...
union all select null, something2, ...
What are the rules to make these queries right?
Thanks a lot. mcibor
You can't select null. you can only select columns and null is a keyword (the same as order or date).
To select null values you need to pass:
SELECT bla WHERE bla IS NULL;
If not null then:
SELECT bla WHERE bla IS NOT NULL;
You cannot use bla = NULL - this is wrong!