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

J

Jimenda

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
 
D

Douglas J. Steele

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...)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top