Re: [win32,mysql v. 3.23.32]Now() function and ERROR in enum
Christian, a DEFAULT value in a CREATE (or ALTER) statement must be a static value, try using a TIMESTAMP field instead. To use 'ERROR' in as an 'ENUM' DEFAULT it must be included in the definition, i.e. ENUM('ERROR','TRUE') Hope this helps... John On Thursday 08 February 2001 09:09, Christian Ribeaud wrote: Hi, 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 '-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? 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. Greetings, christian - 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
RE: [win32,mysql v. 3.23.32]Now() function and ERROR in enum
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 '-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
Antwort: [win32,mysql v. 3.23.32]Now() function and ERROR in enum
On 08.02.2001 15:09:47 Christian Ribeaud wrote: would like that the table put automatically the today's date for every INPUT as default value. What is wrong? Uhm, why don't you use a timestamp column type then? Okay, it will also save the time, but it's easy to extract only the date, if that's all your after. With a timestamp, you could either not set any value when inserting or set it to NULL which both would enter the current time (like in NOW()). Another question, 'showIt ENUM('TRUE') DEFAULT ERROR' did not work but 'showIt Sure, because your ENUM did not contain the value 'ERROR' - it's just containing 'TRUE'. 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 I use a TinyINT and store a 0 for FALSE and something other than 0 (like 1, or whatever) for TRUE. That will only take 1 byte to store what you need. - 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