Mysql
 sql >> Database >  >> RDS >> Mysql

MySQL UNISCI a più tabelle con LIMIT Ultima tabella per DateTime per risultato

Puoi unirti a un "tavolo" creato da una sottoselezione come questa:

SELECT t1.user_id, t1.user_name, t2.department, t3.computer_name, t3.logon_date
FROM table1 AS t1
LEFT OUTER JOIN table2 AS t2 ON t1.user_id = t2.user_id
LEFT OUTER JOIN
(SELECT user_id, computer_name, MAX(last_logon_date) AS `logon_date` FROM table 3 GROUP BY computer_name) AS t3 ON t1.user_id = t3.user_id