In my database there is table as below
+----+-----------+----------+
| id | fk_id | duration |
+----+-----------+----------+
| 1 | 23 | 00:00:31 |
| 2 | 23 | 00:00:36 |
| 3 | 677 | 00:00:36 |
| 4 | 678 | 00:00:36 |
+----+-----------+----------+
In the above table the column duration is of data type time .
The following one is the schema of that table
Create Table: CREATE TABLE `durationof` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`fk_id` int(11) NOT NULL,
`duration` time NOT NULL,
PRIMARY KEY (`id`))
Here the thing just I want to add all times in a duration column in a query, how can I?
Just like sum function is there any function to add all mysql time vales .
I tried select addtime(diration) from durationof;
But that is not working.
I completely disagree with @Corbin’s original answer. As documented under The
TIMEType:To take the summation of all such intervals: convert to seconds, take the sum and then convert back again.
See it on sqlfiddle.