delete records with subquery

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

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

15TH OCTOBER, COUNTY HALL, LONDON

Join us at the Community Lounge.

Register Now

2019 GARNER 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

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

Best Practices for Using Context Variables with Talend – Part 4

Pick up some tips and tricks with Context Variables

Blog

How Media Organizations Achieved Success with Data Integration

Learn how media organizations have achieved success with Data Integration

Read

Agile Data lakes & Analytics

Accelerate your data lake projects with an agile approach

Watch