maharg
Technical User
- Mar 21, 2002
- 184
Hi,
I wonder if you can help steer me in the right direction.
I have a MySQL table which shows when a latching pushbutton was pressed and when it was released, in unix time...
`id`, `pressed`, `released`
128, 1389608227, 1389608232
129, 1389608352, 1389608559
130, 1389608794, 1389608871
131, 1389608884, 1389608898
132, 1389609086, 1389609195
133, 1389609568, 1389609788
134, 1389624513, 1389624517
I am trying to show the total amount of time the button was pressed, within a specified time range, for example
between 1389608400 and 1389619000. The time span can start and stop within a 'pressed' period our outside (between rows).
I have managed to achieve a working result with numerous stitched-together php and mysql combinations, which, although
it does the job, I am sure is over-complicated and will be a pain to maintain, as I have up to 150 buttons to monitor!
Any guidance on an efficient MySQL approach would be much appreciated.
Thanks
Graham
I wonder if you can help steer me in the right direction.
I have a MySQL table which shows when a latching pushbutton was pressed and when it was released, in unix time...
`id`, `pressed`, `released`
128, 1389608227, 1389608232
129, 1389608352, 1389608559
130, 1389608794, 1389608871
131, 1389608884, 1389608898
132, 1389609086, 1389609195
133, 1389609568, 1389609788
134, 1389624513, 1389624517
I am trying to show the total amount of time the button was pressed, within a specified time range, for example
between 1389608400 and 1389619000. The time span can start and stop within a 'pressed' period our outside (between rows).
I have managed to achieve a working result with numerous stitched-together php and mysql combinations, which, although
it does the job, I am sure is over-complicated and will be a pain to maintain, as I have up to 150 buttons to monitor!
Any guidance on an efficient MySQL approach would be much appreciated.
Thanks
Graham