-- 結果検証
SELECT `facility2`.`ID`,
       `facility2`.`Facility`,
       `facility2`.`prefecture_id`,
       `facility2_damages`.`ID`,
       `facility2_damages`.`Facility_ID`,
       `facility2_damages`.`damage_type`,
       `facility2_damages`.`comment`,
       `facility2_damages`.`regist_date`,
       `facility2_damages`.`update_date`
FROM `facility2`
         LEFT OUTER JOIN `facility2_damages` ON `facility2_damages`.`facility_id` = `facility2`.`ID` AND
                                                (facility2_damages.ID = (SELECT dd.ID
                                                                         FROM facility2_damages dd
                                                                         WHERE dd.Facility_ID = facility2.ID
                                                                           AND regist_date > '2019-02-06 00:00:00'
                                                                         ORDER BY dd.regist_date DESC,
                                                                                  dd.update_date DESC,
                                                                                  dd.ID DESC
                                                                         LIMIT 1
                                                )
                                                    )
;

