Hi.

What you observe is the fact that "-1" will be converted to the format
of the index, else the index could not be used.

Converting -1 to an unsigned number give the biggest possible number
for the type in question (here BIGINT UNSIGNED). None of your numbers
is bigger than this, so you get an empty set, i.e. the result you
observe is to be expected.

IIRC, the behaviour without indexes has been fixed in the 4.x version
(to be also an unsigned comparison).

Bye,

        Benjamin.


On Thu, May 16, 2002 at 06:22:56PM +0000, [EMAIL PROTECTED] wrote:
> Hi All,
> 
> Using MySQL server version 3.23.49-nt I get strange results when running 
> the following very simple test.  I am wondering if this is a bug, feature 
> or perhaps a standart SQL behaviour??
> 
> CREATE TABLE test(id BIGINT UNSIGNED);
> CREATE INDEX test_idx on test(id);
> INSERT INTO test VALUES (0), (1), (2), (3);
> SELECT * FROM test WHERE id > -1;
> 
> I get an empty result.  With column type INT UNSIGNED, it's a little bit 
> better; only the 0 is not included in the result set!
> 
> However if I don't put an index on the column, everything seems to behave 
> good.  I recon it has something to do with casting (-1) to an unsigned 
> value. Is (id > -1) a valid and supported comparison on that column after 
> all???
[...]

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

Reply via email to