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
-- Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577
-- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]