我试过
DELETE FROM installments
WHERE EXISTS (SELECT * FROM `installments`
JOIN student
ON installments.s_id=student.s_id
WHERE installments.curr_sem=3
AND student.bat_id=10 AND student.p_id=170 AND student.DeleteStatus=0);
但显示错误
#1093 - 您无法指定目标表格分期付款'用于FROM子句中的更新
请帮帮我
答案 0 :(得分:0)
使用DELETE JOIN尝试此解决方案:
DELETE
i
FROM
installments i JOIN student s USING (s_id)
WHERE
i.curr_sem=3 AND
s.bat_id=10 AND
s.p_id=170 AND
s.DeleteStatus=0
答案 1 :(得分:0)
您的陈述的正确形式如下:
DELETE installments.*
FROM installments
JOIN student ON installments.s_id=student.s_id
WHERE installments.curr_sem=3
AND student.bat_id=10
AND student.p_id=170
AND student.DeleteStatus=0;
如果我理解正确,您只想删除与连接条件匹配的分期付款的记录。您可以在一个表中删除或更新包含连接条件的记录,而不需要嵌套选择。
如果您正在使用Workbench,则必须禁用安全模式,否则如果未在其中指定键列,则会出现错误。
让我得到您的反馈
此致