If in a select?

# Thread: If in a select?

1. Senior Member
Join Date
Dec 1969
Posts
108

## If in a select?

Is it possible to do an if in a select statement?<BR><BR>I have a select statment that compares a record in one table to a record in another table. If a certain field has a value in the first table I want to also compare the data in 2 other tables along with it. If not just continue on. If that is possible what would the syntax look like?<BR>

2. London Guest

## RE: If in a select?

Just like you say it:<BR><BR>Select Case a<BR>case a = somevalue<BR> If a = anothervalue Then<BR> blah, blah<BR> Else<BR> blah, blah<BR> End If<BR>case a = someothervalue...

3. mark Guest

## RE: If in a select?

Yes, it&#039;s called iif()<BR><BR>Use: IIF(condition, true, false)<BR><BR>Look for the documentation on the net.<BR><BR>Example:<BR><BR>SELECT IIf(table1.field1 = "Yes", "field1 is yes", "field1 is not yes") AS Expr1 FROM table1;<BR><BR>Now what you can do is use nested IIf statements. So we could have:<BR>SELECT IIf(table1.field1 = "Yes", "field1 in table1 is yes", IIf(table2.field1 = "Whatever", "field1 in table1 is not yes and field1 in table2 is whatever", "field1 in table1 is not yes and field1 in table1 is not whatever") AS Expr1 FROM table1, table2;<BR><BR>Or something like this. It&#039;s a bad example, I know.<BR>

4. mark Guest

## RE: If in a select?

Yes, it&#039;s called iif()<BR><BR>Use: IIF(condition, true, false)<BR><BR>Look for the documentation on the net.<BR><BR>Example:<BR><BR>SELECT IIf(table1.field1 = "Yes", "field1 is yes", "field1 is not yes") AS Expr1 FROM table1;<BR><BR>Now what you can do is use nested IIf statements. So we could have:<BR>SELECT IIf(table1.field1 = "Yes", "field1 in table1 is yes", IIf(table2.field1 = "Whatever", "field1 in table1 is not yes and field1 in table2 is whatever", "field1 in table1 is not yes and field1 in table1 is not whatever")) AS Expr1 FROM table1, table2;<BR><BR>Or something like this. It&#039;s a bad example, I know.<BR>

5. Senior Member
Join Date
Dec 1969
Posts
108

## Thank you both. <eop>

.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•