Php Mysql查询按月份和年份获取结果

Php Mysql查询按月份和年份获取结果,php,mysql,Php,Mysql,表inventory\u month有三个字段id、month\u month和month\u 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 id月\月\年

inventory\u month
有三个字段
id
month\u month
month\u 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 id月\月\年 1 09 2012 2 10 2012 3 11 2012 4 01 2013 5 02 2013 6 03 2013 7 09 2013 8 10 2013 我需要2012年10月至2013年10月的结果,如下所示

预期结果

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 id月\月\年 2 10 2012 3 11 2012 4 01 2013 5 02 2013 6 03 2013 7 09 2013 8 10 2013 但在下面得到结果

取得成果

id month_month month_year 2 10 2012 8 10 2013 id月\月\年 2 10 2012 8 10 2013 我试过下面的问题

选择id、month\u month、month\u year,其中month\u month>=10、month\u year>=2012和month\u month使用

选择id、month\u month、month\u year,其中
(月>=10,月>=2012)
或

(month\u month您的条件逻辑不正确

您需要将第二个
语句替换为
语句,并添加括号

(month_month>=10 AND month_year>=2012) OR (month_month<=10 AND month_year<=2013).
(month\u month>=10,month\u year>=2012)或(month\u month试试这个

select id,month_month,month_year where (month_month>=10 AND month_year>=2012)
Or (month_month<=10 AND month_year<=2013)
选择id、月月、月年,其中(月月>=10,月年>=2012)

或者(包括2012年9月在内的月份也意味着获取所有记录您需要进行更多编辑才能获得OP的预期记录。@user3218154-试试我的记录。
select id,month_month,month_year where (month_month>=10 AND month_year>=2012)
Or (month_month<=10 AND month_year<=2013)