HI how would i go about counting days holiday taken in one year from the employee start date then every consecutive after that.
Table 1
id name lastname startdate holidays
1 jon homes 2014-10-10 25
Holiday table will have all holidays taken
id empid date
1 1 2014-12-20
2 1 2014-12-21
3 1 2014-12-22
4 1 2015-10-01
5 1 2015-10-02
6 1 2015-10-11 (this would be a new year)
How can I query mysql to count holidays for 12 months form the employees start date then do this every year in the future without hard coding the dates.
I can understand how to do this in the current year
SELECT COUNT(*)
FROM Holiday
WHERE YEAR(date) = YEAR(CURDATE()) AND empid = 1;
So how do i run the query from the startdate 2014-10-10 for 12 months then for every year (the next time the start date would be 2015-10-10 then 2016-10-10 etc.)
Thanks