在第一个表(first_table)之后:
id
data
status
在第二个表(second_table)之后:
id
status
final_result
我想从final_result
等于 3 的第二个表中删除所有结果,并且在status
等于status
先前删除的结果的第一个表中删除所有结果。按照我的查询:
DELETE FROM second_table WHERE final_result = '3'
我不知道如何继续,你能帮帮我吗?
您必须首先删除第一个表的行。
DELETE FROM first_table where status in (select distinct status from second_table where final_result='3')
DELETE FROM second_table WHERE final_result = '3'
DELETE FT, ST
FROM first_table AS FT
JOIN second_table AS ST
ON FT.status = ST.status
AND ST.final_result = '3'