I have a query where I want to find the list of employees whose years of experience is multiple of 5, i.e whose experience is above 5 years, above 10 years, above 15 years etc. Employees who crossed 6 years, list should not display, It should display only employee experience with 5,10,15 years.and so on.
table columns employee id, name, dob, join date.
Can Please anyone help me to get the result
CodePudding user response:
You can get the difference between todays date and the join_date
in years and take all those having a multiple of 5 using the modulo operator
select *
from employees
where timestampdiff(YEAR, join_date, now()) % 5 = 0