• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Group by in mysql

 
Ikasari Widiyanto
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • 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?
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • 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.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Jeanne. never touched something other than oracle. .
did work with DB2 but haven't came across this "Distinct".

thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic