homepage Welcome to WebmasterWorld Guest from 54.235.36.164
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Accredited PayPal World Seller

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
What is better as a default value: NULL or ''?
In the MySQL table...
GreenLeaf




msg:1286650
 7:59 pm on Jan 27, 2005 (gmt 0)

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.

 

jollymcfats




msg:1286651
 8:14 pm on Jan 27, 2005 (gmt 0)

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.

GreenLeaf




msg:1286652
 11:34 pm on Jan 27, 2005 (gmt 0)

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




msg:1286653
 3:12 pm on Jan 28, 2005 (gmt 0)

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!

Best regards
Michal Cibor

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved