SQLServer联表更新,update join

select * from ta s left join tb w on s.sd=w.SheetID
where s.d between '2024-08-12 13:59:00.000' and '2024-08-17 13:59:00.000' and s.w between 100 and 199

先查询确认数据范围再更新,以免误操作

update ta set OrderGld=w.OrderID,OrderSo=w.OrderSO

from ta s left join tb w on s.sd=w.SheetID
where s.d between '2024-08-12 13:59:00.000' and '2024-08-17 13:59:00.000' and s.w between 100 and 199

posted @ 2024-08-15 10:52  enif  阅读(369)  评论(0编辑  收藏  举报
豫ICP备2021034901号