【发布时间】:2020-09-02 10:30:30
【问题描述】:
我需要设计一个界面,用户可以选择年份然后月份,年份可能是几年,并且每年可以选择几个月,然后我需要编写一个select语句来检索数据。我可以通过几个选择语句来做到这一点并将它们联合起来。有没有办法一次性写出来?
这个截图显示了我需要设计的界面:
我写的是这样的:
select *
from yearmonth
where year = '1390' and month in ('1', '2')
union
select *
from yearmonth
where year = '1391' and month in ('3', '4')
union
select *
from yearmonth
where year = '1392' and month in ('5')
union
select *
from yearmonth
where year = '1393' and month in ('1', '2')
【问题讨论】:
标签: sql-server select union