读书人

帮忙解决下初学者的有关问题牙路过的

发布时间: 2011-12-31 23:50:30 作者: rapoo

帮忙解决下菜鸟的问题牙,路过的千万不要错过牙?
查询一张表中重复的记录???

比如
create table a
(
a int,
b int,
)
里面有数据
1,1
2,3
1,1
2,3
4,5
1,1

[解决办法]

create table tb
(
a int,
b int,
)


insert into tb values(1,1)
insert into tb values(2,3)
insert into tb values(1,1)
insert into tb values(2,3)
insert into tb values(4,5)
insert into tb values(1,1)

select tb.* from tb join
(
select tb.a,count(0) as x
from tb
group by tb.a

)qq on tb.a=qq.a
where qq.x <> 1

读书人网 >asp.net

热点推荐