在Talend Open Studio中执行连接查询以进行数据集成

时间:2015-12-15 13:06:05

标签: mysql join sql-update talend data-integration

我是Talend open studio的新手,我需要在作业中执行MySql更新查询。所以我尝试使用tMysqlrow组件并在Query字段中指定查询。当我运行该作业时,它显示"超过锁定等待超时;尝试重启交易"错误。

这是我的SQL查询:

UPDATE library_export AS updater INNER JOIN 
(SELECT id,(max_sequence_3 - coreTable.Level_3_sequence)+1 AS reverse_sequence_3,
(max_sequence_2 - coreTable.Level_2_sequence)+1 AS reverse_sequence_2,
(max_sequence_1 - coreTable.Level_1_sequence)+1 AS reverse_sequence_1 
FROM library_export AS coreTable 
LEFT JOIN 
(SELECT MAX(Level_3_sequence) AS max_sequence_3,Level_2_id 
FROM library_export 
GROUP BY Level_2_id) AS level3 ON (coreTable.Level_2_id = level3.Level_2_id)
LEFT JOIN 
(SELECT MAX(Level_2_sequence) AS max_sequence_2,Level_1_id 
FROM library_export GROUP BY Level_1_id) AS level2 ON (coreTable.Level_1_id = level2.Level_1_id),
(SELECT MAX(Level_1_sequence) AS max_sequence_1 
FROM library_export) AS level1) AS updataBy ON (updater.id = updataBy.id) 
SET updater.Level_1_new_sequence = updataBy.reverse_sequence_1,
updater.Level_2_new_sequence = updataBy.reverse_sequence_2,
updater.Level_3_new_sequence = updataBy.reverse_sequence_3 

有人可以帮我执行更新查询吗?

0 个答案:

没有答案