![]() |
SQL Query - only applying to one where statement!!!!
I have tried to build an sql query to use in a Query Table.
It should be - select * where data = x or data = y and date <= date1 and = date2 what it appears to be doing is querying the date on data y but not on data x, if that makes sense. How can I select by two data types and then dates on all data selected??? |
SQL Query - only applying to one where statement!!!!
Logical "AND" is always performed before logical "OR" operators, therefore
your statment is working as if written like this: where data = x or (data = y and date <= date1 and = date2) try doing this: where (data = x or data = y) and date <= date1 and = date2 "westg" wrote: I have tried to build an sql query to use in a Query Table. It should be - select * where data = x or data = y and date <= date1 and = date2 what it appears to be doing is querying the date on data y but not on data x, if that makes sense. How can I select by two data types and then dates on all data selected??? |
SQL Query - only applying to one where statement!!!!
Also, it looks like something is missing...
where (data = x or data = y) and date <= date1 and DATE = date2 "Charlie" wrote: Logical "AND" is always performed before logical "OR" operators, therefore your statment is working as if written like this: where data = x or (data = y and date <= date1 and = date2) try doing this: where (data = x or data = y) and date <= date1 and = date2 "westg" wrote: I have tried to build an sql query to use in a Query Table. It should be - select * where data = x or data = y and date <= date1 and = date2 what it appears to be doing is querying the date on data y but not on data x, if that makes sense. How can I select by two data types and then dates on all data selected??? |
SQL Query - only applying to one where statement!!!!
Hi westg,
You may have to use parenthesis to group the items in your where clause: SELECT * FROM MyTable WHERE (Data=x OR Data=y) AND MyDate<=Date1 AND MyDate=Date2 -- Regards, Jake Marx MS MVP - Excel www.longhead.com [please keep replies in the newsgroup - email address unmonitored] westg wrote: I have tried to build an sql query to use in a Query Table. It should be - select * where data = x or data = y and date <= date1 and = date2 what it appears to be doing is querying the date on data y but not on data x, if that makes sense. How can I select by two data types and then dates on all data selected??? |
SQL Query - only applying to one where statement!!!!
I also have the same confussion, give me some idea about berween date query *** Sent via Developersdex http://www.developersdex.com *** |
All times are GMT +1. The time now is 07:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com