- 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 s
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 sea
Oh, well, chalk it up to experience. RLIKE is what works the way I want. DOH!
Thanks,
--Scott Brown
At 12:34 PM 10/30/2003, you 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.c
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
Thanks for all of the responses!
Actually, Brent Baisley wins the syntax question of the day. The BETWEEN
syntax is what I needed.
REGEXP and RLIKE do not return any records, they return a count of the
number of rows matching the expression.
Thanks!
--Scott Brown
At 11:22 AM 10/30/2003, you
You can use RLIKE which is regular expressions then you should be able to execute
SELECT * FROM sometable WHERE surname RLIKE '^[A-C]' ORDER BY surname;
Kelley
Scott Brown wrote:
> Hi, List,
>
> I looked here:
>
> http://www.mysql.com/doc/en/String_comparison_functions.html
>
> But I am not see
This should work for you:
SELECT * FROM sometable WHERE surname BETWEEN 'A' AND 'D' ORDER BY
surname
In my quick test the first parameter is inclusive while the second is
not, which is why it is D and not C.
On Thursday, October 30, 2003, at 02:22 PM, Scott Brown wrote:
I want to do a string
Hi, List,
I looked here:
http://www.mysql.com/doc/en/String_comparison_functions.html
But I am not seeing what I need.
I want to do a string comparison like this:
SELECT * FROM sometable WHERE surname LIKE '[A-C]%' ORDER BY surname;
This works in another RDBMS. It doesn't return a syntax erro