使用SQL子查询实现查找唯一值

  发布时间:2025-11-05 09:06:40   作者:玩站小弟   我要评论
复制ifobject_id(Test_Users)isnotnull droptableTest_Users go create 。
使用SQL子查询实现查找唯一值
复制if object_id(Test_Users) is not null   drop table Test_Users   go   create table Test_Users(AutoID int identity(1,使用1) primary key,UserGroupID int,UserName varchar(50))   go   set xact_abort on   begin tran   insert into Test_Users(UserGroupID,UserName)   select 2,aa union   select 2,bb union   select 3,cc union   select 1,Admin union   select 3,ff union   select 2,pp    commit tran   go   select * from Test_Users a   where UserGroupID not in   (select UserGroupID from Test_Users where AutoID<>a.AutoID)   1.2.3.4.5.6.7.8.9.10.11.12.13.14.15.16.17.18.19.20.21.
  • Tag:

相关文章

最新评论