I have two tables: one has a datetime column, the other has a date column.
I want to join the two tables like this:
SELECT
t1.dt,
t2.d
FROM
table1 t1,
JOIN
table2 t2
ON
DATE(t1.dt) = t2.date
But obviously, this kills the index on t1.dt
.
What's the best strategy to get around this? The simplest approach would be to add a new column to t1
(and set it equal to date(t1.dt)
), but I don't like the idea of duplicating data.
Is there a neat way to get around this?