Can I use an "If" statement in my critera of my query?

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

Guest

Can I use an "If" statement in the critera of my query? If so, I am trying
to return a value from a table in one column based on the condition of
another column? Is this fesible? How do I do it?

Thanks
Jim
 
Can you give an example?

If what you're trying to do is return Field3 as the second value in your
query if Field5 has one value, or Field4 otherwise, the simplest approach
would be to have two subqueries and UNION them together:

SELECT Field1, Field3
FROM MyTable
WHERE Field5 = "X"
UNION
SELECT Field1, Field4
FROM MyTable
WHERE Field5 <> "X"

Note that the query will not be updatable (but then, it wouldn't be with any
solution I can think of for this problem...)
 
Back
Top