Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: can wild cards be used in BETWEEN clause

Re: can wild cards be used in BETWEEN clause

From: VC <boston103_at_hotmail.com>
Date: Tue, 13 Apr 2004 00:43:42 GMT
Message-ID: <1JGec.25788$rg5.42057@attbi_s52>


Hello Roger,

> On Mon, 12 Apr 2004 23:27:42 +0100, Andy Hassall <andy_at_andyh.co.uk> wrote:
>
> >
> > BETWEEN doesn't accept wildcards,
>
> So how come this works?

You are quite right about BETWEEN accepting 'wildcards'. However, the following statement is incorrect:

<quote>
It seems to me perfectly logical. Show me everything between A and B should not show me B itself, because I've asked for things *between* two points, but not the points themselves.
</quote>

The between predicate implies a closed, not open interval, i.e. an interval that includes its boundaries as well. You can easily verify this with numeric data which are probably easier to understand than string data. As for the example above, it works as it should.

Consider a set of strings like this {'a', 'ab', 'kl', 'z', 'za'}.

The following predicate, BETWEEN 'a%' and 'z%' will select {'ab', 'kl'} because 'a' < 'a%' so it's not included in the subset; however 'z' < 'z%' and IS included ( but 'za' > 'z%' and it's skipped). This predicate, BETWEEN 'a' and 'z', naturally will select {'a', 'ab', 'kl', 'z'}.

VC Received on Mon Apr 12 2004 - 19:43:42 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US