I've hit a SQL query problem (Access database).
In a table, entries can be one of about half a dozen different types; additionally (regardless of type) there is a true/false entry.
I want to bring out entries of three types only, but ONLY those for which the true/false is also true.
Currently I have a statement in the form:
strSQL = "SELECT tblTable.* FROM tblTable WHERE tblTable.Type = 'type1' OR tblTable.Type = 'type2' OR tblTable.Type = 'type3' AND tblTable.TrueFalse = True;"
Unfortunately, this seems to bring back ALL 'type1' records, ALL 'type2' records, and 'type3' records which are also "True"; in psuedo-mathematical notation it's doing:
type1 OR type2 OR (type3 AND True)
When I want:
(type1 OR type2 OR type3) AND True
i.e., I want it to find all type1, 2 and 3 records which are True; it's only applying the True/False criteria to the last selected type. I need to force the statement to consider each "OR" first, and then consider the "AND" section.
Help!
PS. I've tried putting the True/False criteria first, then AND...type1 OR...type2 OR type3, it makes no difference beyond doing "(True AND Type1) OR type2 OR type3"
PPS. I don't really want to duplicate the "AND" section after each or the Type selection sections, mainly because it looks ugly and there must be a neater way!
Ta
Edited by pedalcars