Re: Multiple AND statements
- From: "Stefan B Rusynko" <sbr_enjoy@xxxxxxxxxxx>
- Date: Fri, 7 Apr 2006 05:48:53 -0400
Logic error
- make your 3rd condition the 1st condition
In any select with OR the 1st criteria met will yield the results
(even if any further tests could also yield results)
And the results are determined from left to right
(so the 1st test that fails, yields an F, determines the test result)
- in your case test 1 and test 2 already have determined the results of test 3 before it is even seen
Look at your code as simple Boolean tests
- below is annotated w/ simple results as XtestT/F meaning results of comparison are True or False
SELECT * FROM Results
WHERE
(Name='::SelectName::' AND Activity='::SelectActivity::')
(NtestT/F and AtestT/F) which yields T OR F (test1) - say T
OR
(Name='::SelectName::' AND Purpose='::SelectPurpose::')
(NtestT/F and PtestT/F) which yields T OR F (test2) - say T
OR
(Name='::SelectName::' AND Activity='::SelectActivity::' AND Purpose='::SelectPurpose::')
(NtestT/F and AtestT/F and PtestT/F)
is the same as ( test1T/F and PtestT/F ) which yields T OR F (test 3)
- and by this time either test1 or test2 has yielded T so they would have been selected for results
(or if test1 has yielded F, test 3 will always yield F)
--
_____________________________________________
SBR @ ENJOY (-: [ Microsoft MVP - FrontPage ]
"Warning - Using the F1 Key will not break anything!" (-;
To find the best Newsgroup for FrontPage support see:
http://www.frontpagemvps.com/FrontPageNewsGroups/tabid/53/Default.aspx
_____________________________________________
"GAA" <GAA@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message news:2EB1B579-0F09-40B7-8227-F0D26FB7C596@xxxxxxxxxxxxxxxx
|I have written a Custom Query using the Database Results Wizard as follows:
|
| SELECT * FROM Results WHERE (Name = '::SelectName::' AND Activity =
| '::SelectActivity::') OR (Name = '::SelectName::' AND Purpose =
| '::SelectPurpose::') OR (Name = '::SelectName::' AND Activity =
| '::SelectActivity::' AND Purpose = '::SelectPurpose::')
|
| The first two parts of this work fine and return the correct results if only
| two criteria option are selected, however when all three criteria selection
| are selected the the results returned are incorrect, it seems to only
| recognise and match the Name part.
|
| Any ideas?
.
- Prev by Date: Re: Hyperlink wtihin ASP
- Next by Date: Re: ASP and Access Database queries
- Previous by thread: Re: Hyperlink wtihin ASP
- Next by thread: Re: Multiple AND statements
- Index(es):
Relevant Pages
|