我试图用另一个表中的数据更新MySQL中的表。
UPDATE KassaticketRegels
SET soort = (SELECT t3.benaming
FROM KassaticketRegels AS t1 INNER JOIN Diensten AS t2 ON t1.dienst = t2.id INNER JOIN DienstGroepen AS t3 ON t2.dienstGroep = t3.id
WHERE t1.id = KassaticketRegels.id)
但是当我按下去时,我得到错误"#1093 - 表' KassaticketRegels'被指定两次,两者都作为'更新'的目标。并作为数据的单独来源"。
我该如何解决这个问题?
答案 0 :(得分:1)
查看代码似乎需要内部联接的更新
UPDATE KassaticketRegels t1
INNER JOIN Diensten AS t2 ON t1.dienst = t2.id
INNER JOIN DienstGroepen AS t3 ON t2.dienstGroep = t3.id
set t1.soort = t3.benaming