帮我看看这个SQL语句错在那里 ( 积分: 10 )

  • 主题发起人 主题发起人 香烟火山
  • 开始时间 开始时间

香烟火山

Unregistered / Unconfirmed
GUEST, unregistred user!
select zg_id from tb_huiz_bcbx
where zg_id in (select tb_huiz_bcbx from tb_huiz_bcbx having count(zg_id)>1 group by zg_id) order by zg_id
-----
提示
--
服务器: 消息 156,级别 15,状态 1,行 2
在关键字 'group' 附近有语法错误。
 
select zg_id,tb_huiz_bcbx from tb_huiz_bcbx having count(zg_id)>1 group by zg_id
 
还是提示
服务器: 消息 156,级别 15,状态 1,行 1
在关键字 'group' 附近有语法错误。
 
group by 要放在前面如下:
select zg_id from tb_huiz_bcbx
where zg_id in (select tb_huiz_bcbx from tb_huiz_bcbx group by zg_id having count(zg_id)>1 ) order by zg_id
 
我是想把tb_huiz_bcbx 表中所有ID重复的记录列出
 
http://www.delphibbs.com/keylife/iblog_show.asp?xid=25352
 
来自:szq1979, 时间:2007-6-19 9:51:49, ID:3800162
group by 要放在前面如下:
select zg_id from tb_huiz_bcbx
where zg_id in (select tb_huiz_bcbx from tb_huiz_bcbx group by zg_id having count(zg_id)>1 ) order by zg_id

运行后提示
服务器: 消息 207,级别 16,状态 3,行 1
列名 'tb_huiz_bcbx' 无效。
 
select zg_id from tb_huiz_bcbx group by zg_id having count(zg_id)>1
 
你的语法是错的,
select tb_huiz_bcbx from tb_huiz_bcbx having count(zg_id)>1 group by zg_id
前面也要有聚合函数
例如:
select tb_huiz_bcbx,count(zg_id) from tb_huiz_bcbx having count(zg_id)>1 group by zg_id
 
tb_huiz_bcbx?这个不知道是表名,还是字段名?
 
angellover
select zg_id from tb_huiz_bcbx group by zg_id having count(zg_id)>1
只是显示了重复 的 ID我要找这个tb_huiz_bcbx 表中所有重复的要列出所有列
 
select zg_id from tb_huiz_bcbx
where zg_id in (select zg_id from tb_huiz_bcbx group by zg_id having count(zg_id)>1) order by zg_id

你要把id重的列出应这样吧
 
把tb_huiz_bcbx 表中所有ID重复的记录列出:
select * from tb_huiz_bcbx
where zg_id in (select zg_id from tb_huiz_bcbx group by zg_id having count(zg_id)>1) order by zg_id
 
多人接受答案了。
 
后退
顶部