Instead of inserting NULL, leave the column out.

INSERT mytable (2nd_col_name) VALUES (NULL);

If you don't mention the enum column, it gets the default.

Michael

On Fri, 12 Apr 2002, 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 allowed
>
> Ruben
>
> > 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 your
> > > 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 <[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
>


---------------------------------------------------------------------
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

Reply via email to