Subject Re: [firebird-support] Best index for BETWEEN?
Author Milan Babuskov
Mercea Paul wrote:
>> In an application I'm currently developing I have a lot of parametrized
>> queries like this:
>
>> SELECT * FROM table1 t WHERE :somevalue BETWEEN t.field1 AND t.field2;
>
> Are you sure about this select?

100%

For example, I need to find the range to which the user-supplied value
belongs. Field1 and Field2 can, for example, be a starting and ending
date for some event, and I need to find to which event some date
belongs. It's a little bit more complex than that in real application,
but you get the idea.

> For me looks more logic something like:
>
> SELECT * FROM table1 t WHERE t.id_or_date BETWEEN :param1 AND :param2;

That would be the easy case :)

--
Milan Babuskov
http://www.flamerobin.org
http://www.guacosoft.com