当前位置:首页 >IT科技类资讯 >使用SQL子查询实现查找唯一值 正文

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

来源:益强资讯优选   作者:数据库   时间:2025-11-05 12:08:21
使用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.

标签:

责任编辑:数据库

图片精选