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.
> 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.
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?
> 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.
lyric2002 - 13 Jul 2005 14:37 GMT
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.
> 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
[quoted text clipped - 6 lines]
> >
> > Thanks in advance.
Tim Ferguson - 13 Jul 2005 18:28 GMT
> 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