djk是学员表。想查询身份证有重复,显示出名字来
select * from djk a ,(select sfzhm,count(sfzhm) as sj from djk group by sfzhm order by sj having sj>1) b where a.sfzhm=b.sfzhm
提示语法错误,请帮看下什么问题
?
没有错误呀。只是你后面要引用字段可能有问题了,似乎应该改为
select a.*,sj from djk a ,(select sfzhm,count(sfzhm) as sj from djk group by sfzhm order by sj having sj>1) b where a.sfzhm=b.sfzhm