SQL 更新 top1 行查询 [英] SQL update top1 row query
本文介绍了SQL 更新 top1 行查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下查询有效:
update top(1) ShipBillInfo
set shipfirstname='kkk'
where CustomerId='134';
但是如果我尝试按某个 Id 订购它会显示错误:例如:
but it is showing error if i try to order by some Id: for example:
update top(1) ShipBillInfo
set shipfirstname='kkk'
where CustomerId='134'
order by
OredrGUID desc;
推荐答案
With cte as (
select top(1) shipfirtsname
From ShipBillInfo
where CustomerId='134'
order by OredrGUID desc)
Update cte set shipfirstname='abc';
这篇关于SQL 更新 top1 行查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文