I have MySQL table which has logId
as the foreign key
The other table has logId
as one column and corresponding startDate
and endDate
I want to write a JOIN in a way such that my output provides difference between startDate
and endDate
(in hours) for every server.
I have written the following JOIN
but need help to calculate to the difference in dates and show it as TotalTime
select server, totaltime from table1
inner join table2 on table1.logId = table2.logId
SELECT
t1.server,
TIMESTAMPDIFF(HOUR,t2.StartDate, t2.EndDate) AS TotalTime
FROM
table1 t1
LEFT JOIN table2 t2 ON t1.logId = t2.logId