我想删除kontext(column_name)值,这些值具有与fmea值不同而不同于null的子字符串。我可以通过以下查询选择这些值:
select *
FROM fmea001
where substring_index(kontext, ".", 1)
not in (Select substring_index(kontext, ".", 1)
from fmea001
where fmea is not null
and lkey = 9) 但是当我试图删除
delete *
FROM fmea001
where substring_index(context, ".", 1)
not in (Select substring_index(context, ".", 1)
from fmea001
where fmea is not null
and lkey = 9)) 我知道这个错误
错误代码: 1093。不能指定目标表“fmea001”以便在FROM子句中进行更新
您知道另一种方法来执行删除语句吗?谢谢!
发布于 2020-10-29 15:07:44
MySQL dodes不支持对子查询中正在修改的表(更新表或删除表)进行重新设置。
如果我正确地理解了你,你可以把它写成一个反左的联接:
delete f
from fmea001 f
left join fmea001 f9
on substring_index(f9.kontext, '.', 1) = substring_index(f.kontext, '.', 1)
and f9.fmea is not null
and f9.lkey = 9
where f9.fmea is nullhttps://stackoverflow.com/questions/64593679
复制相似问题