I want get the time used for a case so I can create an overview.
The SELECT query for the cases looks like this:
SELECT bc.id, bc.title, bc.estimateCurrent FROM cases bc
For one case I can get the used time like this:
SELECT SUM(TIME_TO_SEC(TIMEDIFF(dateEnding, dateBeginning))) AS calculatedTime FROM timesheet WHERE `#case` = ?
How do I connect both so I have one value for the overview SELECT query? Basically I would want the table to look like this:
id|title|estimateCurrent|timeusedinsec 1|case1| 20| 2000 2|case2| 40| 2500 3|case3| 70| 0
Is that possible? I didn't want to have a for each query on the php side which would result in several queries. Would a view help?