我正在尝试使用此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)
答案 0 :(得分:4)
DELETE
FROM Swears
WHERE Member = 36
ORDER BY Date DESC
LIMIT 1; -- for the first row
答案 1 :(得分:0)
DELETE FROM <table_name>
where <member_column> = <member_value>
ORDER BY Date DESC LIMIT 1