LEFT OUTER JOIN with conditions (where, order by)?
问题 I'm working on a Rails3 project with MySql (local) and Postgresql (Heroku) databases. I need to put conditions on a LEFT OUTER JOIN but I don't know how. I have 2 tables TRAININGS and TRAINING_HISTORIES. I want to retrieve all the records of TRAININGS and add the last valid (aka finished) associated record of TRAINING_HISTORIES. table TRAININGS id name order_by 5 A 1 6 B 2 7 C 3 table TRAINING_HISTORIES id training_id finished_at score 43 5 2011-06-06 10 44 5 null null 45 6 2011-07-07 11 46 6