access表中删除相同的数据,是都删掉一条也不留。
比如 1
2
2
9
8
处理后变成
1
9
8
请各位大侠帮忙帮忙给偶步骤和语句啊,不胜感谢!在线等……
比如 1
2
2
9
8
处理后变成
1
9
8
请各位大侠帮忙帮忙给偶步骤和语句啊,不胜感谢!在线等……
解决方案 »
- 在一个表中,有字段time1,value.如果time1超过现在的时间,则value=1,否则value=0.
- 关于联机丛书中一个备份例子的疑惑
- 急,求高手解决sql服务器更新操作慢的问题!!(100分)
- sqlserver 除数为零的问题
- 菜鸟问题!各位帮忙
- sqlserver存储过程返回table如何实现?
- 急,排序问题~~
- 求sql【复制同一表记录,但有两个字段需要修改--详情 Btn_oncliek】
- 新年的第一声祝福,各位数据库的兄弟姐妹,新年快乐:)
- 关于sql server2000不能正常连接exchange 2000 的配置文件
- 急急急!!!!!在安装SQL 时出现的错误提示!!
- 这个错误什么意思?
delete 表名 where 字段 in(select 字段 from 表名 group by 字段 having count(1)>1)
--或者:
delete a from 表名 a,(select 字段 from 表名 group by 字段 having count(1)>1)b
where a.字段=b.字段
create table s(a int)
insert into s
select 1 union all
select 2 union all
select 2 union all
select 9 union all
select 8--删除重复
delete a from s a,(select a from s group by a having count(1)>1)b
where a.a=b.a--查看
select * from s
insert @t select 1
insert @t select 2
insert @t select 2
insert @t select 9
insert @t select 8 delete @t where id in(select id from @t group by id having count(*)>1)
select * from @t
/*
id
-----------
1
9
8
*/
---
DELETE tb.*
FROM tb
WHERE c1 IN
(
SELECT c1 FROM ttt
GROUP BY c1
HAVING COUNT(c1)>1
)
from t1 t
where
(select count(*) from t1 where ID=t.ID)>1
delete tb where id not in (select id from tb group by id having count(id)=1)
--or
delete tb where id in (select id from tb group by id having count(id)>1)
DECLARE @t TABLE(id INT)
INSERT INTO @t
SELECT 1 UNION ALL
SELECT 2 UNION ALL
SELECT 2 UNION ALL
SELECT 9 UNION ALL
SELECT 8 DELETE FROM @t WHERE id IN (SELECT id FROM @t GROUP BY id HAVING COUNT(id)>1)
if object_id('tb') is not null
drop table tb
go
create table tb
( a int)
insert into tb select 1
union all select 2
union all select 2
union all select 9
union all select 8
go----------------
delete t from tb t join (select* from tb group by a
having(count(*)>1)) b
on t.a=b.a
select * from tb
delete * from tb where id in (select id from tb group by id having count(id)>1)
delete tb where id in (select id from tb group by id having count(id)>1)
delete tb where id in (select id from tb group by id having count(id)>1)
WHERE (SELECT COUNT(*) FROM tb WHERE id=a.id)>1