我有以下UPDATE查询:
UPDATE cl INNER JOIN bb ON cl.r_si = bb.si
SET cl.s_si = (SELECT si FROM bb AS y
WHERE y.si = bb.si+1
AND
(y.p >=bb.p*(1+(bb.imax+y.dmax-((bb.imax-bb.dmax)-((bb.iminn+bb.dminn)-bb.rminn)))/100)
OR
y.p<=bb.p*(1+(bb.imin+y.dmin+((bb.imax-bb.dmax)-((bb.iminn+bb.dminn)-bb.rminn)))/100)))
WHERE (((cl.s_si) is null));
这将返回消息“操作必须使用可更新的查询”
这是与SELECT而不是UPDATE相同的查询:
SELECT
(SELECT si FROM bb AS y
WHERE y.si = bb.si+1
AND (y.p>=bb.p*(1+(bb.imax+y.dmax-((bb.imax-bb.dmax)-((bb.iminn+bb.dminn)-bb.rminn)))/100)
OR
y.p<=bb.p*(1+(bb.imin+y.dmin+((bb.imax-bb.dmax)-((bb.iminn+bb.dminn)-bb.rminn)))/100))) AS s_si
FROM cl INNER JOIN bb ON cl.r_si = bb.si;
该查询在SELECT公式中起作用。为了避免出现此错误消息,我必须在UPDATE查询中进行哪些更改?有必要更新表cl而不创建新的表。