At 21:11 -0500 11/10/04, Michael Stassen wrote:
>Toro Hill wrote:
>>I have question about how the function quote() works with NULL
>>values. Here is what the mysql manual say:
>>Quotes a string to produce a result that can be used as a properly
>>escaped data value in an SQL statement. The string is returned
>>surrounded by single quotes and with each instance of single quote
>>(`''), backslash (`\'), ASCII NUL, and Control-Z preceded by a
>>backslash. If the argument is NULL, the return value is the word
>>``NULL'' without surrounding single quotes. The QUOTE() function
>>was added in MySQL 4.0.3.
>>mysql> SELECT QUOTE('Don\'t!');
>> -> 'Don\'t!'
>>mysql> SELECT QUOTE(NULL);
>> -> NULL
>>Now after reading this I thought that select quote(NULL) would
>>return the string 'NULL' (without quotes) and not the NULL value.
>>However, this is not true on the version of mysql that I'm using:
>You've misunderstood, then. Without the quotes, NULL is the NULL
>value, not a string. You have to have quotes to be a string! NULL
>is NULL, 'NULL' is a string. MySQL is doing exactly what the manual
It's not. The manual says that if the argument is NULL, the return
value is _the word_ NULL without quotes. In other words, it's a string
but the string doesn't include surrounding quotes.
QUOTE() is supposed to produce values similar to what you get with the
DBI quote() function.
Paul DuBois, MySQL Documentation Team
Madison, Wisconsin, USA
MySQL AB, www.mysql.com