View Full Version : Is there a way to apply a different filter to each column in a table?


danwells
04-18-2007, 06:45 AM
Is there a way to apply a different filter to each column in a table without the filters affecting each other?

FoFa
04-18-2007, 10:11 AM
Yes and No.
Most likely OR will get you what you want.
Filters are going to effect each other, but you can use a UNION query to create a recordset of different rows using different criteria.
Lets say Table1 has 3 columns, and you want everything in Col1 that is a 3, and everything in Col2 that is a D. WHERE Col1 = 3 AND Col2 = "D" only gives you where both are meet that crietera. However:
Select Col1, Col2, Col3 from Table1 WHERE Col1 = 3
UNION
Select Col1, Col2, Col3 from Table1 WHERE Col2 = "D"

will give all UNIQUE rows where either COL1 was a 3 or Col2 was a "D"

This is a simplistic example and could have been accomplished with an OR statement as well rather than a UNION, but sometimes a UNION is easier than a really complexe AND/OR structure.

danwells
04-20-2007, 10:13 AM
Thank you very much