List:General Discussion« Previous MessageNext Message »
From:Hans Zaunere Date:November 21 2002 11:18pm
Subject:Re: DATETIME Masking and Comparison
View as plain text  
--- "Keith C. Ivey" <keith@stripped> wrote:
> On 21 Nov 2002, at 14:38, Hans Zaunere wrote:
> 
> > I've played around with a couple different methods, but the only way I
> can
> > see to use the INDEX (according to EXPLAIN) is doing a query along the
> > lines of:
> > 
> > ... WHERE thecolumn BETWEEN '2002-11-17' AND '2002-11-18'
> 
> You don't explain what you don't like about using that method.  If it 
> works, why are you still searching?

Because it seems ineffncient to me, as MySQL must be doing more work to
calculate the range.  Even EXPLAIN tells me this, by showing that a
less-than-optimal TYPE is being used.  Although "WHERE thecolumn =
'2002-11-17'" doesn't yield any results, EXPLAIN shows that it's using a
better index type.

> If the problem is that you don't want to have to calculate the next 
> date, then use 
> 
>    ... WHERE thecolumn BETWEEN '2002-11-17 00:00:00' AND
>        '2002-11-17 23:59:59'

This is so much the problem, as I can easily pass what I want to via the host
language, but yes, it's just another reason why a straight comparison would
be nice.



=====
Hans Zaunere
New York PHP
http://nyphp.org
hans@stripped
Thread
DATETIME Masking and ComparisonHans Zaunere21 Nov
  • Re: DATETIME Masking and ComparisonKeith C. Ivey22 Nov
    • Re: DATETIME Masking and ComparisonHans Zaunere22 Nov
      • Re: DATETIME Masking and ComparisonKeith C. Ivey22 Nov
        • Re: DATETIME Masking and ComparisonHans Zaunere22 Nov
          • Re: DATETIME Masking and ComparisonNicholas Elliott22 Nov
          • Re: DATETIME Masking and ComparisonKeith C. Ivey22 Nov
            • Re: DATETIME Masking and ComparisonHans Zaunere22 Nov
              • Re: DATETIME Masking and ComparisonKeith C. Ivey22 Nov