MySQL BETWEEN Problems
am 18.05.2007 21:56:35 von Tony Grimes
I'm using BETWEEN to return a list all people who's last names fall between
A and F:
..... WHERE last_name BETWEEN 'A' AND 'F' ...
but it's only returning names between A and E. The same thing happens when I
use:
..... WHERE last_name >= 'A' AND last_name <= 'F' ...
Shouldn't this work the way I expect it? What am I doing wrong?
Tony
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: MySQL BETWEEN Problems
am 18.05.2007 22:18:24 von Brad Bonkoski
I think you need between 'A' and 'F%'
Aa is between A and F
but 'Fa' is not between 'A' and 'F'
(but 'Ez' would be between 'A' and 'F')
-B
Tony Grimes wrote:
> I'm using BETWEEN to return a list all people who's last names fall between
> A and F:
>
> .... WHERE last_name BETWEEN 'A' AND 'F' ...
>
> but it's only returning names between A and E. The same thing happens when I
> use:
>
> .... WHERE last_name >= 'A' AND last_name <= 'F' ...
>
> Shouldn't this work the way I expect it? What am I doing wrong?
>
> Tony
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: MySQL BETWEEN Problems
am 18.05.2007 22:29:45 von Tony Grimes
We tried that and it didn't work. We've also tried every combination of
upper and lower case too.
Tony
On 5/18/07 2:18 PM, "Brad Bonkoski" wrote:
> I think you need between 'A' and 'F%'
>
> Aa is between A and F
> but 'Fa' is not between 'A' and 'F'
> (but 'Ez' would be between 'A' and 'F')
> -B
>
>
> Tony Grimes wrote:
>> I'm using BETWEEN to return a list all people who's last names fall between
>> A and F:
>>
>> .... WHERE last_name BETWEEN 'A' AND 'F' ...
>>
>> but it's only returning names between A and E. The same thing happens when I
>> use:
>>
>> .... WHERE last_name >= 'A' AND last_name <= 'F' ...
>>
>> Shouldn't this work the way I expect it? What am I doing wrong?
>>
>> Tony
>>
>>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: MySQL BETWEEN Problems
am 18.05.2007 22:51:31 von Dan Shirah
------=_Part_71416_16829158.1179521491853
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
So just change it to WHERE last_name BETWEEN 'A' AND 'G' . That'll get you
Aa-Fz :)
On 5/18/07, Tony Grimes wrote:
>
> We tried that and it didn't work. We've also tried every combination of
> upper and lower case too.
>
> Tony
>
>
> On 5/18/07 2:18 PM, "Brad Bonkoski" wrote:
>
> > I think you need between 'A' and 'F%'
> >
> > Aa is between A and F
> > but 'Fa' is not between 'A' and 'F'
> > (but 'Ez' would be between 'A' and 'F')
> > -B
> >
> >
> > Tony Grimes wrote:
> >> I'm using BETWEEN to return a list all people who's last names fall
> between
> >> A and F:
> >>
> >> .... WHERE last_name BETWEEN 'A' AND 'F' ...
> >>
> >> but it's only returning names between A and E. The same thing happens
> when I
> >> use:
> >>
> >> .... WHERE last_name >= 'A' AND last_name <= 'F' ...
> >>
> >> Shouldn't this work the way I expect it? What am I doing wrong?
> >>
> >> Tony
> >>
> >>
> >
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
------=_Part_71416_16829158.1179521491853--
Re: MySQL BETWEEN Problems
am 18.05.2007 23:00:14 von Brad Bonkoski
Try using the substr, since you are only comparing the first letters...
(sorry I did not reply all on the other email, Dan)
i.e.
select name from users where substr(name, 1, 1) >= 'A' and substr(name,
1, 1) <= 'B';
-B
Dan Shirah wrote:
> So just change it to WHERE last_name BETWEEN 'A' AND 'G' . That'll
> get you
> Aa-Fz :)
>
>
> On 5/18/07, Tony Grimes wrote:
>>
>> We tried that and it didn't work. We've also tried every combination of
>> upper and lower case too.
>>
>> Tony
>>
>>
>> On 5/18/07 2:18 PM, "Brad Bonkoski" wrote:
>>
>> > I think you need between 'A' and 'F%'
>> >
>> > Aa is between A and F
>> > but 'Fa' is not between 'A' and 'F'
>> > (but 'Ez' would be between 'A' and 'F')
>> > -B
>> >
>> >
>> > Tony Grimes wrote:
>> >> I'm using BETWEEN to return a list all people who's last names fall
>> between
>> >> A and F:
>> >>
>> >> .... WHERE last_name BETWEEN 'A' AND 'F' ...
>> >>
>> >> but it's only returning names between A and E. The same thing happens
>> when I
>> >> use:
>> >>
>> >> .... WHERE last_name >= 'A' AND last_name <= 'F' ...
>> >>
>> >> Shouldn't this work the way I expect it? What am I doing wrong?
>> >>
>> >> Tony
>> >>
>> >>
>> >
>>
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: MySQL BETWEEN Problems
am 18.05.2007 23:09:09 von Tony Grimes
--B_3262345750_5159704
Content-type: text/plain; charset="ISO-8859-1"
Content-transfer-encoding: quoted-printable
Yeah, but what do I do for Q-Z? I guess I=B9ll have to write a condition to
use last_name >=3D =8CQ=B9 if it finds a Z. I=B9ll have to write conditions to look
for other exceptions too. Aaarrgh!
*looks up at the Gods*
Damn you BETWEEN! Why must you torture me so!?!
Have a good weekend.
On 5/18/07 2:51 PM, "Dan Shirah" wrote:
> So just change it to WHERE last_name BETWEEN 'A' AND 'G' . That'll get y=
ou
> Aa-Fz :)
>=20
> =20
> On 5/18/07, Tony Grimes wrote:
>> We tried that and it didn't work. We've also tried every combination of
>> upper and lower case too.
>>=20
>> Tony
>>=20
>>=20
>> On 5/18/07 2:18 PM, "Brad Bonkoski" wrote:
>>=20
>>> > I think you need between 'A' and 'F%'
>>> >
>>> > Aa is between A and F
>>> > but 'Fa' is not between 'A' and 'F'
>>> > (but 'Ez' would be between 'A' and 'F')
>>> > -B
>>> >
>>> >
>>> > Tony Grimes wrote:
>>>> >> I'm using BETWEEN to return a list all people who's last names fall
>>>> between
>>>> >> A and F:
>>>> >>
>>>> >> .... WHERE last_name BETWEEN 'A' AND 'F' ...
>>>> >>
>>>> >> but it's only returning names between A and E. The same thing happe=
ns
>>>> when I=20
>>>> >> use:
>>>> >>
>>>> >> .... WHERE last_name >=3D 'A' AND last_name <=3D 'F' ...
>>>> >>
>>>> >> Shouldn't this work the way I expect it? What am I doing wrong?
>>>> >>
>>>> >> Tony
>>>> >>
>>>> >>
>>> >
>>=20
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>=20
>=20
>=20
--B_3262345750_5159704--
Re: MySQL BETWEEN Problems
am 18.05.2007 23:12:23 von Tony Grimes
Nice! That did the trick. Thanks Brad. I live to fight another day.
Tony
On 5/18/07 3:00 PM, "Brad Bonkoski" wrote:
> Try using the substr, since you are only comparing the first letters...
> (sorry I did not reply all on the other email, Dan)
>
> i.e.
>
> select name from users where substr(name, 1, 1) >= 'A' and substr(name,
> 1, 1) <= 'B';
>
> -B
> Dan Shirah wrote:
>> So just change it to WHERE last_name BETWEEN 'A' AND 'G' . That'll
>> get you
>> Aa-Fz :)
>>
>>
>> On 5/18/07, Tony Grimes wrote:
>>>
>>> We tried that and it didn't work. We've also tried every combination of
>>> upper and lower case too.
>>>
>>> Tony
>>>
>>>
>>> On 5/18/07 2:18 PM, "Brad Bonkoski" wrote:
>>>
>>>> I think you need between 'A' and 'F%'
>>>>
>>>> Aa is between A and F
>>>> but 'Fa' is not between 'A' and 'F'
>>>> (but 'Ez' would be between 'A' and 'F')
>>>> -B
>>>>
>>>>
>>>> Tony Grimes wrote:
>>>>> I'm using BETWEEN to return a list all people who's last names fall
>>> between
>>>>> A and F:
>>>>>
>>>>> .... WHERE last_name BETWEEN 'A' AND 'F' ...
>>>>>
>>>>> but it's only returning names between A and E. The same thing happens
>>> when I
>>>>> use:
>>>>>
>>>>> .... WHERE last_name >= 'A' AND last_name <= 'F' ...
>>>>>
>>>>> Shouldn't this work the way I expect it? What am I doing wrong?
>>>>>
>>>>> Tony
>>>>>
>>>>>
>>>>
>>>
>>> --
>>> PHP Database Mailing List (http://www.php.net/)
>>> To unsubscribe, visit: http://www.php.net/unsub.php
>>>
>>>
>>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: MySQL BETWEEN Problems
am 19.05.2007 00:40:43 von itoctopus
I remember I had the same problem for the between dates.
for example, Select * FROM the_table WHERE the_date BETWEEN '2007-01-01' AND
'2007-01-31', the problem that it wasn't including the 2007-01-31, I
discovered later on that it should be something like:
SELECT * FROM the_table WHERE the_date BETWEEN '2007-01-01' AND '2007-01-31
23:59:59'
--
itoctopus - http://www.itoctopus.com
"Tony Grimes" wrote in message
news:C2737215.330FE%contact@tonygrimes.com...
Yeah, but what do I do for Q-Z? I guess I¹ll have to write a condition to
use last_name >= OQ¹ if it finds a Z. I¹ll have to write conditions to look
for other exceptions too. Aaarrgh!
*looks up at the Gods*
Damn you BETWEEN! Why must you torture me so!?!
Have a good weekend.
On 5/18/07 2:51 PM, "Dan Shirah" wrote:
> So just change it to WHERE last_name BETWEEN 'A' AND 'G' . That'll get
> you
> Aa-Fz :)
>
>
> On 5/18/07, Tony Grimes wrote:
>> We tried that and it didn't work. We've also tried every combination of
>> upper and lower case too.
>>
>> Tony
>>
>>
>> On 5/18/07 2:18 PM, "Brad Bonkoski" wrote:
>>
>>> > I think you need between 'A' and 'F%'
>>> >
>>> > Aa is between A and F
>>> > but 'Fa' is not between 'A' and 'F'
>>> > (but 'Ez' would be between 'A' and 'F')
>>> > -B
>>> >
>>> >
>>> > Tony Grimes wrote:
>>>> >> I'm using BETWEEN to return a list all people who's last names fall
>>>> between
>>>> >> A and F:
>>>> >>
>>>> >> .... WHERE last_name BETWEEN 'A' AND 'F' ...
>>>> >>
>>>> >> but it's only returning names between A and E. The same thing
>>>> >> happens
>>>> when I
>>>> >> use:
>>>> >>
>>>> >> .... WHERE last_name >= 'A' AND last_name <= 'F' ...
>>>> >>
>>>> >> Shouldn't this work the way I expect it? What am I doing wrong?
>>>> >>
>>>> >> Tony
>>>> >>
>>>> >>
>>> >
>>
>> --
>> PHP Database Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
>
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php