At 15:22 -0700 12/16/03, Knepley, Jim wrote:
I've got a WHERE clause:
WHERE possibly_null_value IS NULL

That works fine. This null-safe equal doesn't do what I expect:
WHERE possibly_null_value <=> NULL

The manual, and my testing, shows that NULL <=> NULL evaluates to 1, so

Are you saying that this is not what you expect? Why not?


my now-fevered mind sees no reason the two above statements are not
equivalent.

IS NULL can be used only to test whether or not something is NULL. <=> can be used to test NULL or any other value.

col_name1 IS NULL is true only if col_name1 is NULL.
col_name1 <=> col_name2 is true if col_name1 is the same as col_name2,
even when they're both NULL
col_name1 = col_name2 is true if col_name1 is the same as col_name2,
but only if both are *not* null.


What I _really_ want to do is this: WHERE possibly_null_value <=> INET_ATON(<IP>)

...so that if no IP is specificied it'll return those
possibly_null_value columns that are, in fact, NULL.

Your requirements are unclear. I can see two ways to interpret that statement:

1) You want only possibly_null_value values that are NULL.
2) You can possibly_null_value values that are NULL *and*, if IP is specified,
possbly_null_value values that are equal to INET_ATON(IP).

Those are not the same thing.  (In other words, it's clear what you
want only for the case that IP is NULL.  It's not clear what you want
when IP isn't NULL.)  Can you clarify?

(Just as a test I've also tried possibly_null_value <=> NULLIF(
ISNULL(INET_ATON(<IP>)), 1 ), which is wrong for my app, but still
broken)

MySQL 4.0.15-standard

Any insight would be much appreciated.


--
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]



Reply via email to