Question : How do I update my tables in mysql to include new data?

If I have a table with results of races, and that table has both raceID and racerID, how can I check to see that every racerID is included at least once in for every raceID.  So if I have this:

resultsID   raceID  racerID
1     215     34
2     215     32
3      209    32
4     208    32
5     208     34
6     204      32


...how would I update this table to make sure racerID 34 now has a record for having been in raceID 208.  Right now there's 8 different raceID's per table, and if a racer wasn't in all of them, I need to update it to show a record for 0 points in every race if they didn't participate.

Thanks!
Kevin

Answer : How do I update my tables in mysql to include new data?

for a named racer (208)
this is generating all missing  race results!
 
insert into results (raceid,racer,result)
 select raceid,208,0
   from races as r
 where not exists (select resultid from results as x  
           where x.raceid=r.raceid and x.racer=208)


for every racer (208)
this is generating all missing  race results!
insert into results (raceid,racer,result)
 select raceid,rs.racer,0
   from races as r,racers as rs
 where not exists (select resultid from results as x  
           where x.raceid=r.raceid and x.racer=rs.racer)
Random Solutions  
 
programming4us programming4us