- use master
- go
- create table users
- (
- id int primary key identity(1,1),
- name varchar(20) not null
- )
- go
- insert into users values('phe')
- insert into users values('pho')
- insert into users values('phe')
- insert into users values('phy')
- insert into users values('phj')
- insert into users values('phy')
- select * from users
- select name from users where id in(select a.id from users as a,users as b where a.id!=b.id and a.name=b.name)