如何使用update语句运行SQL查询,where子句和order by / [英] How to run SQL query with a update statement, where clause and order by/

查看:644
本文介绍了如何使用update语句运行SQL查询,where子句和order by /的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Can someone please help I keep on getting this error: The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions unless TOP, OFFSET or FOR XML is also specified. This is the query I'm using:





我尝试过:





What I have tried:

UPDATE  SMS 
SET idx30 = 'New' 
WHERE idx30 in (SELECT * 
    FROM SMS 
    WHERE
    idx30 IS NULL
    AND 
    (idx15 = 'Del' OR idx15 = 'Fail')
    AND 
    Idx13 <> '1'
    AND
    Idx7 >= DATEADD(day, -1, GETDATE()) 
    ORDER BY idx7 DESC);

推荐答案

错误信息非常明确:

The error message is pretty clear:
Quote:

ORDER BY子句无效视图,内联函数,派生表,子查询和公用表表达式,除非还指定了TOP,OFFSET或FOR XML。

The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions unless TOP, OFFSET or FOR XML is also specified.

尝试删除它,或者将TOP或OFFSET添加到让它变得有价值 - 没有它们,它没有任何有用的功能。

Try removing it, or add TOP or OFFSET to make it worthwhile - without them, it serves no useful function.


你好,

参考: 这个答案

谢谢
Hello,
Refer : this answer
Thanks


这篇关于如何使用update语句运行SQL查询,where子句和order by /的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆