File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes Remove duplicate value from resultset Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Remove duplicate value from resultset" Watch "Remove duplicate value from resultset" New topic
Author

Remove duplicate value from resultset

khamhielle gabriel
Greenhorn

Joined: Aug 15, 2011
Posts: 19
Hi,


can somebody give me a hand on this:

i was trying to avoid printing duplicate data from the database

where in whenever i call from the database, most of the other values are just reprinted because there is one unique value.
what i need to do is to just print only what is unique on its given group.

Example of repeated values:

1234av Casie 5678
1234aw Shel 5762
1234aw Shel 0998
1234ax nica 9754

needed output :

1234av Casie 5678
1234aw Shel 5762 0998 ---* the unique value should be printed at the side rather than creating the whole set of line again.
1234ax nica 9754


sorry i'm really poor on loops please help me. thanks

and God Bless

ps: i was printing it on a text file
Gerald Lam
Greenhorn

Joined: Aug 23, 2010
Posts: 6
Hm, I'm not sure if there's a better way to do it, but in my opinion, you could use a Map to store the values, so and check if there's a duplicate, if there is, get the value and append the new value to it.
For the key, you could combine both, for example, from the code you've given, 1234aw,Shel. And if you need to use the key, just split it with ",".
 
 
subject: Remove duplicate value from resultset
 
Similar Threads
Passing values between PHP pages without navigation
How to store unique elements in List?
Marcus Green Q=21 Collection
Hibernate: need to make a value unique, but still allow nulls
How to interpret results of println when printing user defined object