我不确定这是怎么回事:
DELETE t1 FROM modified_client_config AS t1, modified_client_config AS t2
WHERE t1.Date < t2.Date AND t1.Client = t2.Client AND t1.Server = t2.Server;
我在问问题之前进行了搜索,发现使用别名删除时有一条规则:
DELETE f FROM dbo.foods AS f WHERE f.name IN (...)
那么,可以将这种语法用于别名吗?
我知道它是具有两个别名的同一张表,但我想我的同事写此表仅在date1
答案 0 :(得分:2)
似乎您只想为client
和server
的每种组合保留最新的行。
您可以使用相关的子选择来做到这一点:
delete from modified_client_config as t1
where exists (select *
from modified_client_config as t2
where t2.date > t1.date
and t2.client = t1.client
and t2.server = t1.server);