简体   繁体   中英

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.

Do you mean this which is 10 Oct 2008 to 8th Nov 2009 inclusive

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

or this which is 10 Oct 2008 to 9th Nov 2009 inclusive

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

Edit: Removed SQL Server references

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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