1、创建测试表,插入数据:
1
2
3
4
5
6
7
8
9
10
11
12
13
create table product
(id int,
name varchar(10),
totol int)
insert into product values (1,'香蕉',100)
insert into product values (2,'橘子',67)
insert into product values (3,'葡萄',89)
insert into product values (4,'苹果',235)
insert into product values (5,'香蕉',77)
insert into product values (6,'芒果',34)
insert into product values (7,'葡萄',78)
insert into product values (8,'梨',24)
表中数据如:
2、如果查询name列有重复的数据,可执行sql语句:
1
select * from product where name in (select name from product group by name having COUNT(*)>1)
说明:查询的结果就是香蕉和葡萄在表中是有重复的
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)