Testify whether values of one table exists in another table

483 Views Asked by At

I've created a new query and added a new data item to it. The data item is of Boolean type. I'd like to write an "if... else..." expression to define it. If a data in table1.field1 exists in table2.field2, it returns "Yes". Otherwise, it returns "No". My question is, how to write the "if" expression?

I've tried both:

"(table1.field1) in (table2.field2)"

and

"(table2.field2) contains (table1.field1)"

but neither of them can pass the format validation.

Anyone help me?

1

There are 1 best solutions below

0
On

This is in report Studio? In your data item expression window, you look in the f(x) tab under the 'constructs' folder you'll find the format for if then else

IF ( <condition> ) THEN
    ( <expression> )
ELSE 
    ( <expression> )

You'll need something like

IF ( [Field1] LIKE '%' || [Field1] || '%' ) THEN
    ( 'Y' )
ELSE 
    ( 'N' )