[英]select where year = specific range of years
In my table I have a range of start and end years, example below: 在我的表格中,我有一个范围的开始和结束年份,如下所示:
id start year end year
1 2005 2007
2 2008 2012
3 2009 2012
4 1998 1999
5 2005 2006
I want to select only those that are between the years 2005 and 2006 我只选择2005年到2006年之间的那些
I'm sure this is very simple to someone else but I cannot get my head around it! 我相信这对其他人来说非常简单,但我无法解决!
EDIT : 编辑:
Just seen the answers and realised how dumb this question was! 刚看到答案,就意识到这个问题有多愚蠢! For some reason I was thinking that doing that was wrong!
由于某种原因,我认为这样做是错误的!
select *
from YourTable
where [start year] <= 2006
and 2005 <= [end year]
您应该将简单子句与> = <=一起使用
SELECT * FROM table WHERE `start_year`>= 2005 AND `end_year` <= 2006
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.