Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
kakooo16
Creator
Creator

How could use context variable with OR clause in sql

Hello ,

I have query

Select

x

,

y

,

z

,

w

from

table_name

Where

(

x

=

900

)

AND

( (

y

=

'F01'

)

OR

(

y

=

'CIP'

)

OR

(

y

=

'T01'

)

OR

(

y

=

'U01'

)

OR

(

y

=

'L01'

))

I want to contextialize my variable x and y .

I know that my query would be

Select

x

,

y

,

z

,

w

from

table_name

Where

(context.

x

=

900

)

AND

( (context. y=

'F01'

)

OR

(context.y=

'CIP'

)

OR

(context.y=

'T01'

)

OR

(context.y=

'U01'

)

OR

(context.y=

'L01'

))

How could i put different values into the same context variable X ?

Labels (2)
2 Replies
gjeremy1617088143

Hi ,

first :

 

AND

( (context. y=

'F01'

)

OR

(context.y=

'CIP'

)

OR

(context.y=

'T01'

)

OR

(context.y=

'U01'

)

OR

(context.y=

'L01'

))

 

--> AND context.y in ('F01','CIP','T01','U01','L01' )

second :

If you want multiple values you can separate your values by a delimiter in you context variable ex : "900;800;700;600"

then you use a tnormalize with ; as separator on this value,

then you iterate with a tflowtoiterate and you use the globalMap value of the field of the tflowtoiterate in your query.

Send me Love and Kudos

Anonymous
Not applicable

The query looks like:

"Select x,y,z from tablename where x=“+context.x+" and y in "+context.y

before executing the query, you can set the value of context variable on tJava/tJavaFlex component, eg:

...tJava--onComponentOK--tMysqlInput--main--...

on tJava:

context.x="900";

context.y="('T01','U01','D01')";

 

Regards

Shong