How to update and order by using ms sql

前端 未结 5 1342
粉色の甜心
粉色の甜心 2020-11-28 08:35

Ideally I want to do this:

UPDATE TOP (10) messages SET status=10 WHERE status=0 ORDER BY priority DESC;

In English: I want to get the top

5条回答
  •  广开言路
    2020-11-28 09:05

    UPDATE messages SET 
     status=10 
    WHERE ID in (SELECT TOP (10) Id FROM Table WHERE status=0 ORDER BY priority DESC);
    

提交回复
热议问题