Hey how can I combine the two queries below into one?? so I get the result set as one becuase the first query is getting the points results from a table and the table below is getting the rest that I need from another table, but there both related to eachother as when the first query is excuted is could do the secound query with it. I just don’t know how? any help is great.
SELECT t.team_id, t.teamname, t.code, t.value,
SUM(Case When track_id = (SELECT MAX(track_id) FROM team_stats) Then points Else 0 End) lastracepoints,
SUM(points) AS points
FROM team_stats ts
Left Join teams t
on t.team_id = ts.team_id
GROUP BY ts.team_id
SELECT SUM(IF(qual_pos = '1', 1,0)) AS poles,
SUM(IF(race_pos <= '3', 1,0)) AS podiums,
SUM(IF(race_pos = '1', 1,0)) AS victories,
SUM(overtakes) AS overtakes
FROM driver_stats s
left join drivers d
on d.drivers_id = s.drivers_id
GROUP by d.team_id
I think the join options of mysql can help you out here.