1

我写的查询是:

delete from featured where featuredID IN(
select top(@removeAmnt) * from featured 
order by featured.createdon asc)

这似乎不起作用。我得到的错误是,“当 EXISTS 没有引入子查询时,选择列表中只能指定一个表达式。”。我不熟悉 sql 查询。我基本上试图通过他们的 createdon 字段来订购这些默认值是日期函数。同样, sp 允许传入一个值 removeAmnt,这是将从顶部选择的要删除的表条目的数量。

4

2 回答 2

2

您很可能需要删除*

delete from featured where featuredID IN(
select top(@removeAmnt) featuredID  from featured 
order by featured.createdon asc)
于 2012-08-17T18:54:11.097 回答
0

你没有提到你得到了什么结果,但你在 in 子句中的选择不应该是 * 而是 featuresID。

delete from featured 
where featuredID IN(
                    select top(@removeAmnt) featured.featuredid from featured 
                    order by featured.createdon as
                    )
于 2012-08-17T18:53:47.673 回答