I am trying to select the rows for given range of year and month. (i.e.: from <start year>+<start month> to <end year>+<end month>)
I tried the below query but I am getting unexpected rows. Am I missing something?
SELECT * FROM table AS t
WHERE
((YEAR(t.column1)='<start year>' AND MONTH(t.column1)>='<start month>') OR
(YEAR(t.column1)>'<start year>' AND YEAR(t.column1)<'<end year>') OR
(YEAR(t.column1)='<end year>' AND MONTH(t.column1)<='<end month>'))
You may try something like this:
This will should perform better, as it will use index from column
column1.