Quantcast
Channel: Convert date in date list condition to list of date ranges - Database Administrators Stack Exchange
Viewing all articles
Browse latest Browse all 4

Convert date in date list condition to list of date ranges

$
0
0

I want to look for all the records that occur on specific dates.

SELECT *FROM table1WHERE date(column) in ($date1, $date2, ...);

However, as many of you, know this kind of comparison doesn't get along with indexes. So, I was wondering if there is a simple way to convert this query to something of the style of the following query without too much effort (i.e., : not using an external tool).

SELECT *FROM table1WHERE (column >= $date1 AND column < $date1 + interval 1 day)   OR (column >= $date2 AND column < $date2 + interval 1 day)   ...

So the optimizer can still use the indexes. (I'm using MySQL, but ANSI SQL would be great)


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images