Mysql
 sql >> Base de données >  >> RDS >> Mysql

Requête MySQL - Jointure interne utilisant uniquement la dernière version d'une entrée

SELECT  a.*, c.*
FROM    jobs a
        INNER JOIN
        (
            SELECT jobID, MAX(time) maxVal
            FROM purchaseOrders
            GROUP BY jobID
        ) b ON a.jobID = b.jobID
        INNER JOIN purchaseOrders c
            ON c.jobID = b.JobID AND
                c.time = b.maxVal