在更新左连接期间占用最长时间 mysql

Take maximum time during update left join mysql

我正在对 ID 和接收器进行更新左连接。

Left table
Id | Receiver | Order Time | guid | item
12 | abc      | 12:35      | NULL | NULL


Right table
Id | Receiver | Time taken | guid  | item
12 | abc      | 50seconds  | yuhb2 | 0
12 | abc      | 189seconds | vef3  | 2

如何进行查询以选择花费时间最长的记录?

update tableA a left join TableB b
ON  a.ID=b.ID
AND    a.receiver = b.receiver
set
a.items= b.items
where a.guid is null;

预期输出:

Left table
Id | Receiver | Order Time | guid | item
12 | abc      | 12:35      | vef3 |  2

我在 right_table 中添加了另一列 (id_primary)。 要在末尾使用此子查询 (select id_primary from right_table order by time_taken desc limit 1) 获得最大值

 update left_table a left join right_table b
    ON  a.id= b.id
    set
    a.item= b.item,
    a.guid= b.guid
    where a.guid is null
    and b.id_primary = (select id_primary from right_table order by time_taken desc limit 1 )