Subject Re: BETWEEN Operator Inclusive?
Author Svein Erling
Hi Jack!

BETWEEN is inclusive, it is just that 'DA' > 'D'. Hence, in your case
I would use something like

Select * from TABLE
Where NAME Between 'A' and 'DZZZZZZZZZZZZZZZZZZZZZZZZZZZ'

(or the largest letter appropriate)

The same goes for any other datatype, the one to look out for is
TimeStamp. Even though it is inclusive,

Select * from TABLE
Where SOMEDATE Between '22.03.2004' and '26.03.2004'

will not include '26.03.2004 00:00:01' or greater.

But as I said, it IS inclusive up until the very point you give it. It
is just that things marginally more (according to human thought) is
not included.

HTH,
Set




--- In firebird-support@yahoogroups.com, "jackmills75" wrote:
> Hi
>
> How do I obtain all from a table where a varchar column "starts
> with" a range of values.
> I used the BETWEEN operator because I thought it was inclusive of
> the values, reading various articles indicates that it is (although
> I haven't seen a specific example for characters), but when I
> execute this query
>
> Select * from TABLE
> Where NAME Between 'A' and 'D'
>
> Only strings starting with 'A' to 'C' are returned.
> NAME is VARCHAR(32).
>
> Whereas this does return inclusive values
> Select * from TABLE
> Where TAG_NO BETWEEN 1 and 8
>
> TAG_NO is Int.
>
> Thanks for any help / explanation