sql where条件联动排除范围写法
name | year | month | day |
---|---|---|---|
aa | 2019 | 2 | 28 |
ab | 2020 | 2 | 18 |
ab | 2020 | 2 | 28 |
要查找时间在2020年的,并且排除2月的20-29号。
select * from table where year=‘2020’ and ((month = 2 and day<20) or month <> 2);
select * from table where year=‘2020’ and not (month = 2 and day>=20);