> I tried the following code:
>
> CREATE TABLE news (... published date DEFAULT 'NOW()' NOT NULL,
> ..., showIt ENUM('TRUE') DEFAULT ERROR, ...);
>
> and I was surprised to get an '0000-00-00' as date after doing a
> SELECT. I would like that the table put automatically the today's
> date for every INPUT as default value. What is wrong?
First of all, you're trying to use the STRING 'NOW()' as a
default value in a DATE field. MySQL will try to convert this
string to a date on every insert, fail, and use the zeroed date
instead.
Secondly, MySQL does not accept functions as default values.
You should use the function only on INSERT.
> Another question, 'showIt ENUM('TRUE') DEFAULT ERROR' did not
> work but 'showIt ENUM('TRUE','FALSE') DEFAULT FALSE' worked fine.
> I would like to have something like bits or boolean values in my
> table. How to achieve this? Thanks for the help and have a nice day.
ERROR cannot be a default value, unless you specify it as part of
the enumeration. If you need TRUE/ERROR, define ERROR instead of
FALSE. If you need a tri-state value, use 'TRUE', 'FALSE', 'ERROR'
as the enumneration values.
... or I don't get what you're trying to do...
/ Carsten
--
Carsten H. Pedersen
keeper and maintainer of the bitbybit.dk MySQL FAQ
http://www.bitbybit.dk/mysqlfaq
---------------------------------------------------------------------
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