select id from (select id,count(id) as n from 档案表 group by id) as a where n>1
select IDCardfrom (select IDCard,count(IDCard) as n from Archive group by IDCard) as a where n>1
不过俺还想多嘴问一下,这样的sql 语句,hql能写出来么?
lz的问题就有毛病,什么叫找相同的id,再把id取出来?你都知道id了还找什么id, "select id from Archive where id=?" 然后你只要用 PreparedStatement类中的setString方法设置id值就行了,这样就能完成你说的从表中取出id相同的id的值了,不过有必要这么做吗?
select * from Archive where IDCard='身份证号';
select id from (select id,count(id) as n from 档案表 group by id) as a where n>1
select IDCardfrom (select IDCard,count(IDCard) as n from Archive group by IDCard) as a where n>1
"select id from Archive where id=?"
然后你只要用
PreparedStatement类中的setString方法设置id值就行了,这样就能完成你说的从表中取出id相同的id的值了,不过有必要这么做吗?