tags:

views:

68

answers:

2

Can a set in MySQL be 0?

+1  A: 

Sure, why not?

CREATE TABLE t_set (id INT NOT NULL PRIMARY KEY, value SET('one', 'two'));

INSERT
INTO    t_set
VALUES  (1, 1);

SELECT  *
FROM    t_set;


id    value
----  ------
   1  one

UPDATE  t_set
SET     value = 0;

SELECT  *
FROM    t_set;

id    value
----  ------
   1
Quassnoi
+1  A: 

A SET is a string object that can have zero or more values, each of which must be chosen from a list of allowed values specified when the table is created. SET column values that consist of multiple set members are specified with members separated by commas (“,”). A consequence of this is that SET member values should not themselves contain commas.

For example, a column specified as SET('one', 'two') NOT NULL can have any of these values:

'' 'one' 'two' 'one,two'

http://dev.mysql.com/doc/refman/5.1/en/set.html

Anjisan