I have cobbled together a query
select * where ID1 OR ID2 OR ID3 = 5
but I can't get the query
select * where name="Test" AND (ID1 OR ID2 OR ID3=5).
I can't get the AND filter to work the results of the ID OR Filter.
Thanks!
Sorry I was abbreviating....it is setup like that.
Select * From tbl WHERE tbl.Name="Test" AND (tbl.ID1=5 OR tbl.ID2=5 OR tbl.ID3=5).
I want to find all of the records where the Name is Test and the ID is 5 in any of the 3 ID Fields.
Sorry, I think you meant that you want to select all those records named test with ID 5. The WHERE clause should be:
WHERE (((tbl.Name)="Test" AND ((tbl.ID1)=5)) OR (((tbl.Name)="Test" AND ((tbl.ID2)=5)) OR (((tbl.Name)="Test" AND ((tbl.ID3)=5));
If you only put "Test" in the Criteria once it'll return "Test" and ID1=5 and the rest will be ID2=5 and ID3=5 regardless of whether or not the Name is Test.
Select *
From tbl
Where Name="Test" AND (ID1=5 OR ID2=5 OR ID3=5)
This should work fine. Writing the Name criteria with each ID field is unnecessary if you use the parentheses. Make sure your table has rows that do and don't meet this criteria and run it again.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.