有月份复选框,年份复选框和以下代码(伪代码):
if(month.checked) query = select* from tab where month=month.text;
if(year.checked) query = select* from tab where year=year.text;
if(month.checked and year.checked) query = select * from tab where month=month.value and year=year.value
if(!month.checked and !year.checked) query = select* from tab
如您所见,有 4 个不同的查询。是否可以在一个查询中更快地完成?