Results 1 to 3 of 3
Aug 1, 2012, 20:03 #1
When do I use NULL as Default value for SET, CHAR, VARCHAR data types?
I have two questions. One is about the SET data type. The other is about the CHAR and VARCHAR data types.
Question 1 regarding SET
I am trying to figure out when it is proper to use NULL as one of the values.
For example, if I need no value do I use an empty value like this:
set('', 'Yes', 'No')
or would it be best to set it to NULL like this:
set('NULL', 'Yes', 'No')
On this page in the MySQL manual it uses NOT NULL for the SET value at the top of the page. However, about 1/8 way down the page it says that SET values are sorted numerically and that NULL values sort before non-NULL SET values.
Question 2 regarding CHAR, VARCHAR
Same as question above. If I need just an empty value in a table cell do I use NULL in the database table or do I just use a blank table cell.
For the INT data types: I am having to use NULL for the int types because if I use an empty value PHP will display a "0" in the browser instead of no value.
I would appreciate any information.