database,sql,query
>Paul DuBois writes:
>> At 6:03 PM -0300 5/24/01, Adriano Nagelschmidt Rodrigues wrote:
>> >
>> >level ENUM('bad', 'good', 'great') NOT NULL
>
>[snip]
>
>> >SELECT * FROM foo WHERE level >= 'good'
>
>[snip]
>
>> >Shouldn't a numeric context be applied by the server in this case? eg,
>>
>> Why? 'good' isn't a number, and it's perfectly legal to compare strings
>> with the >= operator.
>
>Because you can (actually, you do) define whatever order you want in
>the ENUM declaration (even alphanum order).
True, and although that's used for sorting, not so for comparisons it seems.
>
>The way it works now, I have to know in which position the label
>'good' is to construct the select. I think this leads to unnecessary
>duplication (is there a function that returns the position of a label?
>I couldn't find it in the manual).
Try this:
SELECT level + 0 from foo where level = 'good' LIMIT 1;
>
>IMHO, if it were abstracted away by the server we would have better
>functionality.
>
>Regards,
>
>--
>Adriano
--
Paul DuBois, paul@stripped
--
Paul DuBois, paul@stripped
| Thread |
|---|
| • Re: Re: SELECT and (ordered) ENUMs | Paul DuBois | 25 May |