Mysql query get result by month and year

bhavesh05

Table inventory_month has three fields id , month_month and month_year

id month_month month_year
1  09          2012
2  10          2012  
3  11          2012
4  01          2013
5  02          2013
6  03          2013
7  09          2013 
8  10          2013

I need result FROM October 2012 TO October 2013 as below

Expected result

id month_month month_year

2  10          2012  
3  11          2012
4  01          2013
5  02          2013
6  03          2013
7  09          2013 
8  10          2013

But getting result below

Getting result

id month_month month_year

2  10          2012 
8  10          2013

I have tried query below

select id,month_month,month_year where month_month>=10 AND month_year>=2012 AND month_month<=10 AND month_year<=2013

Need helpful suggestion, Thanks!

Rikesh

Use,

SELECT id,month_month,month_year WHERE
(month_month >= 10 AND month_year = 2012)
OR     
(month_month <= 10 AND month_year = 2013)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

MySQL Query GROUP BY day / month / year

From Dev

mySql order by query by Year and Month name

From Dev

MySQL Get a list of dates in month, year

From Dev

MYSQL get records before particular month and year

From Dev

How do I create MySQL query to get result from different year?

From Dev

MySQL Query returning all dates instead of specified year and month clauses

From Dev

How to convert this sql to sqlalchemy query? (YEAR, MONTH, COUNT in MySQL)

From Dev

Mysql Month - Year Comparison

From Dev

How can I get the oldest entry (month-year) using month and year table column (int) in mysql?

From Dev

Get current month/year and next month/year?

From Dev

MySQL get result of stmt result for dynamic query

From Dev

Get the month of a year in android?

From Dev

Mysql how to get First Monday of given year and Month

From Dev

MySQL how to get Month and Year with separation like date format

From Dev

Mysql get average and sum of columns and group by year & month

From Dev

MySQL Query: Get new customers in the month

From Dev

MySQL query to get sum where month = January

From Dev

Restructure query to group by month/year

From Dev

Rails: Query ActiveRecord by month and year

From Dev

Crosstab query sort by year and month

From Dev

MySQL: using YEAR_MONTH

From Dev

MySQL filter results by month and year

From Dev

comparing dates by month and year in mysql

From Dev

error in grouping by year,month in mysql

From Dev

Max of month year Mysql/PHP

From Dev

How to sort by month, year in MySQL?

From Dev

Get month by week, day and year

From Dev

TDateTimePicker delphi get year and month

From Dev

Python get last month and year

Related Related

HotTag

Archive