Hi,

No, col BETWEEN 'A' AND 'D' is not the same as col >= 'A' AND col < 'D'.
BETWEEN is equivalent to col >= 'A' AND col <= 'D'. One will include
cols that equal 'D' and the other won't. :-)


Matt


----- Original Message -----
From: "Brent Baisley"
Sent: Thursday, October 30, 2003 3:12 PM
Subject: Re: Need help on WHERE ... LIKE Query


> The BETWEEN operator works like and greater and less than search.
> So, you can do the exact same query like this:
> SELECT * FROM sometable WHERE surname>='A' AND surname<'D'
>
> MySQL may actually optimize them the same way, but using BETWEEN is
> more readable.
>
> To include 'Z', just do a greater than search for what you want:
> SELECT * FROM sometable WHERE surname>='X'
>
> The reason why you would want to do it this way instead of using RLIKE
> is that MySQL will use an index much more efficiently. Do both queries
> with and explain in front of it. You'll see how MySQL performed the
> BETWEEN search, or greater/less than, much more efficiently. If you
> have an index on surname that is.
>
>
> On Thursday, October 30, 2003, at 03:34 PM, Scott Brown wrote:
>
> > Thanks so much Brent, this is what I was looking for.
> >
> > However, what do I do when I get to 'Z'?
> >
> > I looked here, and now I am really confused:
> >
> > http://www.mysql.com/doc/en/Comparison_Operators.html
> >
> > It seems to say that BETWEEN returns a rowcount as well?
> >
> > I am guessing that these all return records...
> >
> > So, what should I use, RLIKE, BETWEEN or???
> >
> > Thanks,
> > --Scott


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to