0

我正在尝试使用此 SQL 查询从具有特定成员的行中删除具有最新日期的表中的行。

此查询选择要删除的正确行:

SELECT *
FROM Swears
WHERE Date = ( 
  SELECT MAX(DATE) 
  FROM Swears
  WHERE Member = 36)

但是此查询不会删除该行。

DELETE
  FROM Swears
  WHERE Date = ( 
    SELECT MAX(DATE) 
    FROM Swears
    WHERE Member = 36)
4

2 回答 2

4
DELETE
FROM Swears
WHERE Member = 36
ORDER BY Date DESC 
LIMIT 1; -- for the first row
于 2013-11-06T06:41:40.053 回答
0
DELETE FROM <table_name>
where <member_column> = <member_value>
ORDER BY Date DESC LIMIT 1
于 2013-11-06T08:40:01.063 回答