X or Y or Z

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to build a query that will show records where ANY of three
different yes/no values have been selected. Any suggestions?
 
Hi Scott,

If you want records where any of the three fields have a yes/no value of
Yes (or True), then the SQL will be something like:
Select * FROM YourTableName WHERE FieldX = Yes OR FieldY = Yes OR FieldZ
= Yes;

To set this up in the query design grid, you need to enter the criteria for
each of the fields in a separate line in the grid.

HTH,

Rob
 
The Yes/No field return -1 for True and 0 for False, so you can try something
like

Select * From TableName Where
([Field1]+[Field2]+[Field3]) <> 0

If all fields will be False then adding them will return 0
 
but maybe the person that comes after you is not going to instantly
recognise the intent of the query, or that the fields are Yes/No.

(Field1 = Yes) OR (Field2 = Yes) OR (Field3 = Yes)

.. tells it as it is.

I would hope that a reader would have faith to recognise
(Field1 OR Field2 OR Field3) as using Boolean (Yes/No) fields as well.

David F. Cox


Ofer Cohen said:
The Yes/No field return -1 for True and 0 for False, so you can try
something
like

Select * From TableName Where
([Field1]+[Field2]+[Field3]) <> 0

If all fields will be False then adding them will return 0

--
Good Luck
BS"D


Scott A said:
I'm trying to build a query that will show records where ANY of three
different yes/no values have been selected. Any suggestions?
 
Back
Top