• 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

Group by in mysql

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have this problem with MySQL.
sql = "select rd.unitcost, rd.quantity, rd.supplier, rh.description from requestdetail rd, requestheader rh where rd.requestNo= rh.requestNo AND rh.requestNo ='"+requestNo+"'order by rh.id asc;";

but when I retrieved, it will be like this:
unitcost quantity supplier description
1 1 1 1
1 1 1 1
1 1 1 1
2 2 2 2
2 2 2 2
2 2 2 2
3 3 3 3
3 3 3 3
3 3 3 3

instead of
unitcost quantity supplier description
1 1 1 1
2 2 2 2
3 3 3 3
which I'm looking for... can somebody help me to solve it?
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can place the word "distinct" or "unique" just after the word "select". but "distinct" is oracle word. hope it will solve your problem.

tip: if more than one column then "distinct" is applied to all the columns mentioned.
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Adeel,
Distinct is a SQL keyword. It isn't Oracle specific.
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Jeanne. never touched something other than oracle. .
did work with DB2 but haven't came across this "Distinct".

thanks.
reply
    Bookmark Topic Watch Topic
  • New Topic