可以在 sql 中做这样的事情:
DELETE TOP 1 FROM items WHERE ItemID = 'xxx' and count(ItemID) > 6 order by index
因此,如果有超过 6 行以 'xxx' 作为 itemID,它会删除比具有该 item id 的那 6 行更新的任何内容?
我认为,我们不能在删除查询中使用top 1。但是我们可以在 where 条件中使用它作为子查询。使用子查询获取数据库 id 列表并将其删除。
DELETE FROM items WHERE id in (select top 1 id from items ItemID = 'xxx' and count(ItemID) > 6 order by index)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句