我的Delete子句怎么了 [英] Whats wrong with my Delete clause
本文介绍了我的Delete子句怎么了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试删除前5行后面的所有行.
I''m trying to delete all the rows that are behind the top 5 rows.
CREATE PROCEDURE DeleteOtherNotes
AS
DELETE FROM notes
WHERE notes_id NOT IN
(SELECT notes_id
FROM
(SELECT notes_id FROM notes ORDER BY notes_id DESC)
foo);
当然,其中的便笺是表,而notes_id是该表的自动编号的ID.
问题是,我会收到此消息:
In which, of course, notes is the table, and notes_id is the auto numbered id of that table.
Problem is, i''ll get this message:
Msg 1033, Level 15, State 1, Procedure DeleteOtherAantekeningen, Line 8<br />
The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP or FOR XML is also specified.
我该怎么办?
What can i do about this?
推荐答案
DELETE FROM notes WHERE (notes_id NOT IN (SELECT TOP 5 notes_id FROM notes))
这篇关于我的Delete子句怎么了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文