Here is my Work table
ID WORK_ID DATE
1 5 2018-05-10
2 6 2018-05-12
3 5 2018-05-15
5 5 2018-05-16
6 6 2018-05-16
.
.
I have a function that calculate business day between dates name kac_is_gunu($date1,$date2) work just fine.
My Question is; It's a big table have too many rows. I want to find difference between every dates for each work_id
For example in this table for work_id 5 kac_is_gunu(2018-05-15,2018-05-10) kac_is_gunu(2018-05-16,2018-05-15)
How can I get the dates like this from this table to my code ?
Here is the result that I want;
2018-05-16 - 2018-05-15 (Pair 1 of work_id 5)
2018-05-15 - 2018-05-10 (Pair 2 of work_id 5)
2018-05-16 - 2018-05-12 (Pair 1 of work_id 6)
.
.
later I will calculate business days between dates
The reason why I'm doing this is; I only have work end dates as date once a work done it means next started so the start date of a work is the end of previous
GROUP BY WORK_ID ORDER BY DATE ASCto get relevant data from DB and then process data with PHP through a loop to get the difference of days between the two dates