0

在第一个表(first_table)之后:

id 
data
status

在第二个表(second_table)之后:

id
status
final_result

我想从final_result等于 3 的第二个表中删除所有结果,并且在status等于status先前删除的结果的第一个表中删除所有结果。按照我的查询:

DELETE FROM second_table WHERE final_result = '3'

我不知道如何继续,你能帮帮我吗?

4

2 回答 2

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'
于 2013-10-16T20:07:32.253 回答
1
DELETE FT, ST
FROM first_table AS FT
JOIN second_table AS ST
ON FT.status = ST.status 
AND ST.final_result = '3'
于 2013-10-16T20:11:20.150 回答