Ruben, I think youare referring to my earlier message, but no matter.
You cannot insert NULL into a column you've defined as NOT NULL, with some special exceptions (auto_increment and timestamp, for example). As I said before, if you want a column to get its default value, you leave it out of the insert. For example, if your_table has 3 columns, col1, col2, and col3, and you want to insert a row with the default value for col2, then instead of INSERT INTO your_table VALUES ('val1', NULL, 'val3'); you say INSERT INTO your_table (col1, col3) VALUES ('val1', 'val3'); Since col2 is not mentioned, it gets its default value. Alternatively, you could explicitly assign the default value. So, in your example 2-column table with the first column enum('No','Yes'), you could either INSERT INTO your_table (other_col) VALUES (NULL); or INSERT INTO your_table (enum_col, other_col) VALUES ('No', NULL); Michael On Fri, 12 Apr 2002, Ruben I Safir wrote: > Your example is not the same, it sends only one value > to a 2 value table. It definetely does not work if you send NULL > > INSERT VALUES(NULL) > > > Ruben > > On 2002.04.12 14:10 Michael Stassen wrote: > > > > On Fri, 12 Apr 2002, Steve Katen wrote: > > > > > Ruben, > > > > > > If you leave it as NOT NULL it should default to NO. "If an ENUM is > > > declared NOT NULL, the default value is the first element of the list of > > > allowed values." > > > > > > SIDE QUESTION: > > > Are you doing something like: select * from table where enum_colum="NO" > > > > > > If you are running that type of query it won't work because enum does not > > > store the values you put in. it stores an index. > > > > Huh? It works for me (in 3.23.44). Consider > > > > mysql> CREATE TABLE enum_test ( > > -> id INT UNSIGNED NOT NULL AUTO_INCREMENT, > > -> enum_column ENUM('No','Yes') NOT NULL, > > -> PRIMARY KEY (id) > > -> ); > > Query OK, 0 rows affected (0.00 sec) > > > > mysql> INSERT INTO enum_test (enum_column) > > -> VALUES ('No'), ('Yes'), ('Yes'), ('No'), ('No'), ('No'), ('Yes'); > > Query OK, 7 rows affected (0.00 sec) > > Records: 7 Duplicates: 0 Warnings: 0 > > > > mysql> SELECT * FROM enum_test WHERE enum_column='No'; > > +----+-------------+ > > | id | enum_column | > > +----+-------------+ > > | 1 | No | > > | 4 | No | > > | 5 | No | > > | 6 | No | > > +----+-------------+ > > 4 rows in set (0.00 sec) > > > > I don't think enums would be very useful if this weren't the case. > > > > Of course, the manual <http://www.mysql.com/doc/E/N/ENUM.html> is very > > unclear on this. It's so busy explaining the the special cases (NULL, > > invalid insert, numerical value, sorting, etc.) that it does not give a > > single example of using the enumerated values in a select or insert. > > That should probably be remedied. > > > > Michael > > > > > > --------------------------------------------------------------------- > > Before posting, please check: > > http://www.mysql.com/manual.php (the manual) > > http://lists.mysql.com/ (the list archive) > > > > To request this thread, e-mail <[EMAIL PROTECTED]> > > To unsubscribe, e-mail <[EMAIL PROTECTED]> > > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > > -- > __________________________ > > Brooklyn Linux Solutions > __________________________ > http://www.mrbrklyn.com - Consulting > http://www.brooklynonline.com - For the love of Brooklyn > http://www.nylxs.com - Leadership Development in Free Software > http://www.nyfairuse.org - The foundation of Democracy > http://www2.mrbrklyn.com/resources - Unpublished Archive or stories and articles >from around the net > http://www2.mrbrklyn.com/mp3/dr.mp3 - Imagine my surprise when I saw you... > http://www2.mrbrklyn.com/downtown.html - See the New Downtown Brooklyn.... > > 1-718-382-5752 > > > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php