Talend Connect
Virtual Summit
JOIN US!
And visit the Customer
& Community Lounge.
May 27-28, wherever you are.

delete records with subquery

Highlighted
One Star

delete records with subquery

I have two tables in two databases (MYSQL & SQL*Server)

I would like to implement, with talend, the following query:

delete from T1 where T1.key in (select t2.key from T2 where T1.key=T2.key and T1.date<T2.date)

is it possible ?

If yes how?

Thanks

Didier

Highlighted
Community Manager

Re: delete records with subquery

Using a tMap to a join between T1 and T2 to get the t2.key, if there exist multiple keys, denomalize all the keys to one line after tMap, write the delete query in a tXXXRow component. eg:
tMysqlInput--main--tMap--main--tDenormalize--main(row2)--tFlowToIterate--iterate--tMssqlRow
                               |
                          lookup 
                              |
                      tMssqlInput

on tMssqlRow, you can write the query as below:
"delete from T1 where T1.key in  "+(String)globalMap.get("row2.columnName")
----------------------------------------------------------
Talend | Data Agility for Modern Business

2019 GARTNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

Best Practices for Using Context Variables with Talend – Part 2

Part 2 of a series on Context Variables

Blog

Best Practices for Using Context Variables with Talend – Part 1

Learn how to do cool things with Context Variables

Blog

Migrate Data from one Database to another with one Job using the Dynamic Schema

Find out how to migrate from one database to another using the Dynamic schema

Blog