"If you insert an invalid value into an ENUM (that is, a string not present
in the list of allowed values), the empty string is inserted instead as a
special error value."
it is inserting the value as the first value in the table which is the
error value or the index of 0.
i would assume that this is the functionality intended.
i also assume that the whole idea of the enum is to pass in values that are
ALWAYS present. so if you are going to run into scenarios that "might"
pass null values you probably shouldn't use enum.
At 01:07 PM 4/12/2002 -0400, Ruben I Safir wrote:
>When I send a NULL it's rejected as bad data, which sort of makes sense
>On 2002.04.12 12:33 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."
>The problem is inserts
>INSERT mytable VALUES (NULL, NULL);
>The first col is defined
>enum('NO', 'YES') NOT NULL
>upon inserting, when it gets a NULL, I want the data accepted and
>defaulted to NO
>This doesn't happen. Instead the insert fails and comes back, NULLs not
> > 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.
> > if you create the table with enum("NO","YES") then you should be able
> to do
> > a select * from table where enum_column=1
> > that should return everything with a NO value.
> > Go read the documentation and see what it has to say:
> > http://www.mysql.com/documentation/mysql/full/manual_toc.html#ENUM
> > katen
> > At 12:24 PM 4/12/2002 -0400, Ruben I Safir wrote:
> > >sql
> > >
> > > > > ENUM can handle your needs. you should be able to just change
> > > syntax
> > > > > to: FIELD ENUM('NO','YES') NULL
> > > > >
> > > > > under that syntax your default value will be NULL.
> > > > >
> > > > I need it to default to 'NO' not NULL
> > ---------------------------------------------------------------------
> > 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 <mysql-thread105978@stripped>
> > To unsubscribe, e-mail
> > 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....