sql语句怎么写啊(50分)

  • 主题发起人 主题发起人 huangjiahan
  • 开始时间 开始时间
H

huangjiahan

Unregistered / Unconfirmed
GUEST, unregistred user!
A表:
zch checkround
001 1
002 1
003 1
001 2
001 3
... 17
如果zch为某个值的checkround共有17条,则删除所有zch为这个值的记录。
这样的sql怎么写?
 
delete from A where checkround='某值'
 
delete a where zch=字段值
 
没看清楚题目吧,某个zch总共有17条,zch是不定的
 
delete from a where checkround=(select count(*) from a);
 
没看清楚题目吧,如果某个zch总共有17条,zch是不定的
则把该zch的记录全部删除掉
 
delete from a where zch=值 and (select count(checkround) from a where zch=值)=17
 
To:雪中漫步
问题zch是不定的啊,怎么办啊
 
delete from a where zch in (select zch from a group by zch having count(*) = 17)
 
select * from zch
然后再:
delete from zch
 
那就干脆
delete from a where zch in (select zch from a group by zch having count(*) = 17)
 
好象表达得不是很明确:记录条数和 checkround 有关系吗?

delete from a where zch in
(select zch from (select zch,count(*) n from a group by 1) b
where b.n=17)
 
存储过程。
 

Similar threads

回复
0
查看
804
不得闲
S
回复
0
查看
1K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
900
SUNSTONE的Delphi笔记
S
S
回复
0
查看
835
SUNSTONE的Delphi笔记
S
S
回复
0
查看
765
SUNSTONE的Delphi笔记
S
后退
顶部