• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Remove duplicate value from resultset

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ",".
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic