Here's my schema and data:
create table person (name char(5)); insert into person values ('Bob'); insert into person values ('Jane');
In mySQL 4.1-alpha, 4.0.15a, and 3.23.58, I get the following results:
mysql> SELECT * FROM person WHERE NOT name = 'Bob'; Empty set (0.00 sec)
mysql> SELECT * FROM person WHERE NOT (name = 'Bob'); +------+ | name | +------+ | Jane | +------+ 1 row in set (0.00 sec)
Why do I need the parentheses? They are not required by the SQL specification. What is the first query really answering?
In MySQL, NOT has higher precedence than =, so your first query is equivalent to (NOT name) = 'Bob'.
Which will compare 1, 0, or NULL to 'Bob', depending on the value of name.
-- Paul DuBois, Senior Technical Writer Madison, Wisconsin, USA MySQL AB, www.mysql.com
Are you MySQL certified? http://www.mysql.com/certification/
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]