我有两个针对oracle的查询。我需要修改它们的MySQL。 首先查询:更新:您无法在FROM子句中指定目标表'表'进行更新
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,但它失败了,我不知道该怎么做。
提供你的努力 – Slowcoder 2014-10-30 15:44:26
对我来说,第二个查询逻辑看上去与'更新tec_onoff_file一 集EMAILTYPE ='REIN的不同 其中transtype =“REIN” 和(EMAILTYPE为NULL或EMAILTYPE查询!= 'RENW')'。 – Slowcoder 2014-10-30 15:53:53
@Slowcoder也谢谢你,你的查询比较容易,并且与Strawberry的查询结果相同。现在我知道,我需要了解更多关于sql的知识。 – RexHunt 2014-10-31 09:22:50