在第一个表(first_table)之后:
id
data
status
在第二个表(second_table)之后:
id
status
final_result
我想从final_result
等于3的第二个表格中删除所有结果,并在第一个表格中status
等于status
之前的结果删除。根据我的询问:
DELETE FROM second_table WHERE final_result = '3'
我不知道怎么继续,你能帮助我吗?
答案 0 :(得分:1)
你必须先删除第一张表的行。
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'
答案 1 :(得分:1)
DELETE FT, ST
FROM first_table AS FT
JOIN second_table AS ST
ON FT.status = ST.status
AND ST.final_result = '3'