Hello. On Mon, Apr 08, 2002 at 11:24:56AM -0400, [EMAIL PROTECTED] wrote: [...] > still...I wonder why I got a 'Query OK, 1 row affected' message.... [...] > > insert into table (key, field) values (1, 'test'||CHAR(59)||' string'); > > > > it seems to work initially...(Query OK, 1 row affected (0.00 sec)) > > but when I try to select the value of the field I get just the > > value '0' (string of zero). [...]
That's because it is a valid expression. In the context of ||, 'test' will be converted to a number. Same for CHAR(59) which returns a string: mysql> SELECT 'test' + 0, 'test' || 0, CHAR(59) || 0, VERSION(); +------------+-------------+---------------+-------------------+ | 'test' + 0 | 'test' || 0 | CHAR(59) || 0 | VERSION() | +------------+-------------+---------------+-------------------+ | 0 | 0 | 0 | 3.23.42-debug-log | +------------+-------------+---------------+-------------------+ 1 row in set (0.00 sec) ORing the expressions with || results in a boolean value which is represented by 1 (true) or 0 (false) respectively. So your insert INSERT INTO table1 (key, field) VALUES (1, 'test'||CHAR(59)||' string') statement boils down to INSERT INTO table1 (key, field) VALUES (1, 0) which is perfectly valid. Well, with some other strings, you could get even a 1 as result :-) mysql> SELECT '21test' || 0, CHAR(53) || 0; +---------------+---------------+ | '12test' || 0 | CHAR(53) || 0 | +---------------+---------------+ | 1 | 1 | +---------------+---------------+ 1 row in set (0.00 sec) Bye, Benjamin. -- [EMAIL PROTECTED] --------------------------------------------------------------------- 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