Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL删除1以外的内容_Sql_Sql Server 2008 - Fatal编程技术网

SQL删除1以外的内容

SQL删除1以外的内容,sql,sql-server-2008,Sql,Sql Server 2008,我的sql中有重复数据,我想删除所有外交官职业安全与健康(安全)姓名,但不删除ID 129 ID -- 57 124 126 127 60 128 129 NAME ==== DiplomaInOccupationalSafety&Health(Security) DiplomaInOccupationalSafety&Health(Security) DiplomaInOccupationalSafety&Health(Security) DiplomaInOccu

我的sql中有重复数据,我想删除所有
外交官职业安全与健康(安全)
姓名,但不删除
ID 129

ID
--
57
124
126
127
60
128
129

NAME
====

DiplomaInOccupationalSafety&Health(Security)
DiplomaInOccupationalSafety&Health(Security)
DiplomaInOccupationalSafety&Health(Security)
DiplomaInOccupationalSafety&Health(Security)
DiplomaInEnforcement&Compliance
DiplomaInOccupationalSafety&Health(Security)
DiplomaInOccupationalSafety&Health(Security)

我已尝试从id=57的表中删除。。。。但我想知道删除所有id(但不包括我想要保留的id)的更快方法这似乎很简单。由于不知道您的表名,我在这里替换了一个通用表名

Delete from table where 
NAME='DiplomaInOccupationalSafety&Health(Security)' and ID<>129
从表中删除,其中
姓名=“外交官职业安全与健康(安保)”和ID129

您使用的是什么数据库,SQL Server还是MySQL?您应该发布您的代码,并询问代码中的具体问题。这个问题不适合So。到目前为止,我设法一个接一个地删除,以避免删除我想要保留的数据库。。。从id=xx的tablename中删除。。。我希望有更快的方法解决我的问题谢谢。你们也谢谢你们对我的帮助。。。但我能理解其中的逻辑,谢谢你为我工作。看看这个哇。。是的,它在小提琴上工作。。。idk为什么我的sql server 2008不工作..工作了!!我忘记了过去;