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

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

equals with multiple data ?

Hi,

In a tMap component, I do this :

"

(

!CAS1.ID.equals("101")

&&

!CAS1.ID.equals("102")

&&

!CAS1.ID.equals("110")

...

)

"

This code is OK but for me, this code is not "nice" and I search to make better this code.

I find something like this in MySQL :

select id from table where id IN ('a', 'b', ...)

It is possible to do something like this with Talend ?

Kind regards.

Labels (3)
3 Replies
Anonymous
Not applicable

Hello,

You can achieve this goal by using tMySqlInput component with context value in your Where clause.

The syntax looks like "SELECT id FROM mytable WHERE id IN '"+context.myvariable + "'"

The best way to approach this is to build your SQL query, output it to the System.out and then test the String you see in a query analyzer. If it works there, it will work in your DB component.

Best regards

Sabrina

 

Mahamoutou
Contributor III
Contributor III

I think below condition using java contains method would be nicer (assuming comma is your separator).

 

! ( "," + "101,102,103,104,105,106" + "," ).contains( ("," + CAS1.ID + ",") )

 

You can easily expand your listOfValues "101,102,103,104,105,106" separated by a comma as you like.

gjeremy1617088143

Hi you can use regular expressions :

!CAS1.ID.matches("101|102|110")

Send me love and kudos