I created a new score table that has a ROR primary key id and checked
Event.find(:all, :select => ‘student_id, name, score, date’, :include
=> :scores)
SELECT event.event_id
AS t0_r0, event.date
AS t0_r1,
event.category
AS t0_r2, rscore.id
AS t1_r0, rscore.student_id
AS t1_r1, rscore.event_id
AS t1_r2, rscore.score
AS t1_r3 FROM
event LEFT OUTER JOIN rscore ON rscore.event_id = event.event_id [0m
so far Rails lists multiple tables in FROM with a Join, but now =>
since all Active record does is parse text and put together mysql bits
and pieces I can write
Score.find :all, :select => ‘student_id, score, date’, :joins => [ ‘,
event’], :conditions => ‘event.event_id = rscore.event_id’
to get
SELECT student_id, score, date FROM rscore , event WHERE
(event.event_id = rscore.event_id)
this generalizes to three tables
Score.find :all, :select => ‘student.student_id, student.name,
rscore.score, event.date’, :joins => [’, event ,
student’], :conditions => ‘event.event_id = rscore.event_id and
student.student_id = rscore.student_id’
ie
SELECT student.student_id, student.name, rscore.score, event.date FROM
rscore , event , student WHERE (event.event_id = rscore.event_id and
student.student_id = rscore.student_id)
My conclusion is most of the time I might as well write Mysql directly
indeed!