خرید بک لینک

Vote count: 0

I have a table with a datetime column which is indexed. I'd like to select all the rows for a specific date. Previously I've been using this:

SELECT *
FROM `table`
WHERE DATE(date_column) = '2016-04-12';

This works fine, however I've been noticing performance issues due to the fact that MySQL does not make use of the index once I apply the DATE() function. I've also tried:

SELECT *
FROM `table`
WHERE SUBSTR(date_column,1,10) = '2016-04-12';

to no avail. So far the only thing that seems to work is:

SELECT *
FROM `table`
WHERE date_column > '2016-04-11'
    AND date_column > '2016-04-13'

This last query successfully uses the index but I'd like to know if there is a way to do this with only a single condition.

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 27 فروردين 1395 ساعت: 1:35

صفحه بندی