I have a same result when I execute both queries from different functions. I just wanted to know which query is optimized or logically correct (see query 1 and 2 below).
I get monthly data with respect to sale.purchase_date
Query 1
SELECT sales.purchase_date FROM `sales`
WHERE sales.purchase_date LIKE '2012-06-%';
Query 2
SELECT sales.purchase_date FROM `sales`
WHERE MONTH(sales.purchase_date) = '6' AND YEAR(sales.purchase_date) = '2012';
Both of those require you to do a table scan because you need to examine the
purchase_dateto see if the row will be in and can’t use an index. I suggest you use aBETWEENquery so you can make use of any index onpurchase_date: