简体   繁体   English

WHERE子句中的多个条件

[英]Multiple conditions within WHERE clause

This query is working fine: 此查询工作正常:

SELECT * FROM tablename where Date >'20091109' and id='11';

But below this query does not return anything. 但是在此查询下面不返回任何内容。

SELECT * FROM tablename 
WHERE Date BETWEEN ('20091109' AND '20081010') AND id='11';
between ('20091109' and '20081010') 

This is anything after 9th Nov 2008 and before 10th Oct 2008. Of course if show nothing. 这是2008年11月9日之后和2008年10月10日之前的任何内容。

Do you mean this which is 10 Oct 2008 to 8th Nov 2009 inclusive 你的意思是这是2008年10月10日至2009年包括 11月8日

Date >= '20081010' AND Date < '20091109'

or this which is 10 Oct 2008 to 9th Nov 2009 inclusive 或从2008年10月10日至2009年11月9日( 含)

Date >= '20081010' AND Date < '20091110'

Edit: Removed SQL Server references 编辑:删除了SQL Server引用

   SELECT * FROM 
   tablename 
   where Date between '20081010' and '20091109' 
   and id='11';

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM