深入学习ing

sqlserver_delete from from inner join_通过表关联查询删除

直接上SQL语句:

 

DELETE FROM TJ_TB_Order FROM dbo.TJ_TB_Order O 
INNER JOIN (SELECT * FROM (
    SELECT OriginID,OriginSiteID,COUNT(1) c,MAX(ID) ID FROM TJ_TB_Order GROUP BY OriginID,OriginSiteID
) A WHERE A.c>1) B ON O.OriginID=B.OriginID AND O.OriginSiteID=B.OriginSiteID AND O.ID=B.ID

 

posted on 2022-09-16 04:17  深入学习ing  阅读(894)  评论(0编辑  收藏  举报

导航