Topic: 用了distinct为什么还是显示重复记录

  Print this page

1.用了distinct为什么还是显示重复记录 Copy to clipboard
Posted by: appleme
Posted on: 2005-05-25 20:21

select distinct username from login
执行之后还是显示重复记录,连接的数据库是sqlserver,请高手指教

2.Re:用了distinct为什么还是显示重复记录 [Re: appleme] Copy to clipboard
Posted by: why
Posted on: 2005-05-27 03:39

Are you sure that the 重复记录 are 重复?

3.Re:用了distinct为什么还是显示重复记录 [Re: appleme] Copy to clipboard
Posted by: appleme
Posted on: 2005-06-02 21:31

是的,我在sqlserver中用distinct查询重复的记录就没有显示,但是在java中,他就全部显示出来了

4.Re:用了distinct为什么还是显示重复记录 [Re: appleme] Copy to clipboard
Posted by: appleme
Posted on: 2005-06-02 21:44

strSQL ="select distinct(taskname) from buildtask where (substring(taskid,1,6)='" + dtaskid + "')";
数据库里的记录如下:
taskid taskname description
001 人格划分1 对人格的划分
002 人格划分1 对人格的划分
003 人格划分2 对人格的划分

请大家帮帮忙,查了好几天的资料,也没查处怎么回事

5.Re:用了distinct为什么还是显示重复记录 [Re: appleme] Copy to clipboard
Posted by: appleme
Posted on: 2005-06-02 21:55

终于解决,我以前的产生statement语句为
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
将其改为stmt = conn.createStatement()执行就正确了。
大家遇到同样的问题可以参考一下

6.Re:用了distinct为什么还是显示重复记录 [Re: appleme] Copy to clipboard
Posted by: why
Posted on: 2005-06-02 23:06

Please tell us which DB and which JDBC driver you are using.
Thanks.

Please try to combine multiple posts in one (using the Editing feature) when they are posted within a short period of time.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923