- 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)
单表查询重复或不重复的记录
本文介绍了如何使用SQL创建表并插入数据,通过具体实例展示了重复数据的查询方法。通过两个表的关联查询来找出重复的名字,加深了对SQL语言的理解。

被折叠的 条评论
为什么被折叠?



