If, then, else SQL select query

L

lyric2002

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

Klatuu

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

David C. Holley

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?
 
L

lyric2002

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

Tim Ferguson

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

Top