gpt4 book ai didi

sql-server - 使用联接时 DELETE 查询出现什么错误

转载 作者:行者123 更新时间:2023-12-02 20:25:37 26 4
gpt4 key购买 nike

在注释 DELETE 语句并尝试使用 SELECT 语句时,代码运行良好。请帮忙

DELETE FROM 
--select * from
Site as s
join
(select SiteID,Code, Name, Dense_rank() over (partition by Code order by SiteID ) as Rank from Site
) as t
on s.SiteID = t.SiteID
WHERE t.Rank != 1

收到以下错误消息

Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'as'.
Msg 156, Level 15, State 1, Line 8
Incorrect syntax near the keyword 'as'.

最佳答案

您无法为 delete 表添加别名,但 delete 可以引用别名。而不是这个:

delete from Site as s
...

尝试:

delete from s
from Site as s
...

关于sql-server - 使用联接时 DELETE 查询出现什么错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11168330/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com