SQL 删除特定范围内的记录 [英] SQL Delete Records within a specific Range
本文介绍了SQL 删除特定范围内的记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
对于有经验的人来说,这可能是一个非常简单的问题,但我只是想知道删除 SQL 表中位于特定范围之间的几百条记录的最安全方法.
This is probably a very simple question for somebody with experience, but I just wanted to know the safest way to delete a couple of hundred records in an SQL table that fall between a specific range.
例如,我需要删除 ID 介于 79 & 之间的行.296:
For example I need to delete rows with an ID between 79 & 296:
我担心的是,如果我说删除带有 ID (>79 AND <296) 的所有内容,那么它实际上可能会擦除整个表格.
My worry is if I say delete everything with an ID (>79 AND < 296) then it may literally wipe the whole table.
推荐答案
如果你使用 Sql Server
if you use Sql Server
delete from Table where id between 79 and 296
在你的编辑之后:你现在澄清你想要:
After your edit : you now clarified that you want :
ID (>79 AND <296)
所以使用这个:
delete from Table where id >79 和 id <296
这篇关于SQL 删除特定范围内的记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文