If, then, else SQL select query

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

Guest

I would like to do a select query based on a list of if, then, else
statements. What is the syntax in an SQL select query?

Thanks in advance.
 
You can use the immediate if (IIF) in queries.
My preferred approach is to create a parameter query, assign values to
variables with If Then Else and set the query's parameters with the variables.
 
SQL is a data access language, it is not a PROGRAMMING language. It is
not possible to put If...then...else statements into a SQL Statement
since SQL does not support If...Thens.

What are you trying to accomplish?
 
Basically I want it to do this:

For each row:
when table1.column1 = 'data' or table2.column1 = 'data' or table2.column2
='data' or table2.column3 = 'data' then 'constant'

I hope this is clear enough, if not let me know.
Thanks.
 
For each row:
when table1.column1 = 'data' or table2.column1 = 'data' or
table2.column2 ='data' or table2.column3 = 'data' then 'constant'

Look up help for the IIF() function. But I strongly suspect a design
problem here...


B Wishes


Tim F
 

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

Back
Top