Skip navigation links

MySQL Forums :: Transactions :: Help Needed With Query - Join?


Advanced Search

Re: Help Needed With Query - Join?
Posted by: Jay Pipes ()
Date: November 29, 2005 12:10PM

Just use a UNION:

(
SELECT horse_no, rider_no, SUM(points) AS total
FROM places
WHERE season_no = 10
AND section_no = 12
GROUP BY horse_no, rider_no
)
UNION ALL
(
SELECT horse_no, person_no, SUM(points) AS total
FROM champs
WHERE season_no = 10
AND section_no = 12
GROUP BY horse_no, person_no
)
ORDER BY total DESC;

Also, be sure to put the proper GROUP BY in your queries. You were outputting horse_no, rider_no, but only grouping on horse_no. This produces unreliable results...

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject Views Written By Posted
Help Needed With Query - Join? 1707 David Bridges 11/27/2005 07:55PM
Re: Help Needed With Query - Join? 1255 Brian Burke 11/29/2005 10:19AM
Re: Help Needed With Query - Join? 1264 Jay Pipes 11/29/2005 12:10PM
Re: Help Needed With Query - Join? 1266 David Bridges 11/30/2005 10:35PM
Re: Help Needed With Query - Join? 1227 Felix Geerinckx 12/01/2005 06:18AM
Re: Help Needed With Query - Join? 1247 David Bridges 12/08/2005 10:45PM
Re: Help Needed With Query - Join? 1214 Jay Pipes 12/09/2005 07:26AM
Help needed in migration 1385 beeresh g 01/31/2006 03:46AM
Re: Help needed in migration 1322 Jay Pipes 02/03/2006 06:16PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.