SQL删除只出现一次的数据

rongguo52013 2011-06-23 05:30:01
删除某字段中只出现一次的数据如
A B C
1 2 3
2 3 4
1 5 6
上面的A字段中2只出现一次,所以要把那条数据数据。改怎么写
...全文
305 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
挨踢直男 2011-06-23
  • 打赏
  • 举报
回复
delete from tb where a in (select a from tb as t where (select count(*) from tb where a = t.a)=1)
灬上海爽爷 2011-06-23
  • 打赏
  • 举报
回复
需要一个标识,比如主键ID,用来区分他们的不同

delete from table t1 where A not in (select A from table where A=t1.A and ID<>t1.ID)
lzp4881 2011-06-23
  • 打赏
  • 举报
回复
delete from table as T where (select count(a) from table where A=T.A)=1

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧