如何使用子查询删除行 - mysql

时间:2013-12-21 06:56:28

标签: mysql

以下在mysql中不起作用,任何替代方式:

DELETE  FROM _ResourceUsageData 
WHERE RowNo >
(SELECT MIN(RowNo) FROM 
_ResourceUsageData 
WHERE
ResourceInstanceStatus = 'Deleted');

1 个答案:

答案 0 :(得分:2)

在Mysql中,您无法从要删除的表中进行选择。但你可以用另一个子查询来欺骗它。

DELETE FROM _ResourceUsageData 
WHERE RowNo > 
(
    select * from 
    (
        SELECT MIN(RowNo) 
        FROM _ResourceUsageData 
        WHERE ResourceInstanceStatus = 'Deleted'
    ) x
)