List:General Discussion« Previous MessageNext Message »
From:Michael Widenius Date:October 6 1999 12:40pm
Subject:Is 'BETWEEN m and n' supposed to work for ENUM fields?
View as plain text  
>>>>> "Terry" == Terry West <terry@stripped> writes:

Terry> In a small test table with 1 enum field and four records
Terry> (with values 'a','b','c' and 'd'), I find the following selects work:

Terry>   select * from enumtest where colname between 'b' and 'c'
Terry>   select * from enumtest where colname > 1 and colname < 4

Terry> but this does not:

Terry>   select * from enumtest where colname between 2 and 3

Terry> Just wondering if the latter is supposed to work.  I've tried
Terry> this test on Linux 3.23.2 and Solaris 3.22.20a.

Hi!

BETWEEN compares the arguments depending on the type of the first
argument.  In your case 'colname' is regarded as a string and the
comparions is done with strings.

Fix:

select * from enumtest where colname+0 between 2 and 3

Regards,
Monty
Thread
Is 'BETWEEN m and n' supposed to work for ENUM fields?Terry West2 Oct
  • Is 'BETWEEN m and n' supposed to work for ENUM fields?Michael Widenius6 Oct