我有两个oracle查询。我需要为mysql修改它们。 第一个查询:
UPDATE tec_onoff_file a
SET emailtype = 'MIGR'
WHERE EXISTS
(SELECT 1
FROM tec_onoff_file
WHERE emailtype = 'MIGR'
AND a.acctnbr = acctnbr
AND a.magabbr = magcodes);
我把它改成了
update tec_onoff_file t1
join tec_onoff_file t2
on t2.emailtype='MIGR'
and t1.acctnbr=t2.acctnbr
and t1.magabbr=t2.magcodes
set t1.emailtype='MIGR';
它有效。 但第二次查询对我来说更难
update tec_onoff_file a
set emailtype = 'REIN'
where transtype = 'REIN'
and curracctnbr not in (select curracctnbr from tec_onoff_file b
where emailtype ='RENW'
and a.curracctnbr=b.curracctnbr);
有人可以帮忙吗?我正在尝试将其更改为第一次使用JOIN查询,但它失败了,我不知道该怎么做。
答案 0 :(得分:0)
UPDATE tec_onoff_file a
LEFT
JOIN tec_onoff_file n
ON b.curracctnbr = a.curracctnbr
AND b.emailtype ='RENW'
SET emailtype = 'REIN'
WHERE a.transtype = 'REIN'
AND b.transtype IS NULL;