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);
本文介绍了一种在SQL查询中使用条件排除特定日期范围的方法。通过示例展示了如何精确地筛选出2020年除2月20日至29日之外的所有记录,使用了两种不同的WHERE子句写法。
123

被折叠的 条评论
为什么被折叠?



