I have these fields on my table
month
year
I wanted to make a query based on this
month BETWEEN 4 AND 12 AND year = 2008
OR
month BETWEEN 1 AND 10 AND year is greater than 2008 but equal or less than 2009
I tried this but doesn't give the right query result.
"WHERE month BETWEEN 4 AND 12 AND year = 2008 OR month BETWEEN 1 AND 10 AND year 2008<=2009";
NOTE: the numbers here are variable, I showed actual number for you to understand easily :) any help?
year = (2008<=2009) means that the year must be greater than 2008 but equal or less than 2009
try this:
where (year*100)+month between 200804 and 200910
This will take care of all the scenarios.. even though difference between the years are more than one
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With