Hi I have a bit of a problem with my SQL. My problem is when I filter the dates of my data, my SQL statement only returns 2 records which was the employee_id of the user.
This is the original statement of my working code that I have in filtering dates:
SELECT * FROM `rmguidef_prs`.`payment_report` WHERE DATE(`Report_Timestamp`) = DATE_ADD(CURDATE(), INTERVAL 24 HOUR) AND Employee_ID IN (
SELECT T1.Employee_ID from `rmguidef_prs`.`employee` T1
WHERE T1.Supervisor_ID = '".$id."')
OR Employee_ID = '".$id."'
This is the modified statement that I need the filters: (its working ok)
SELECT * FROM `report` WHERE Employee_ID IN (
SELECT T1.Employee_ID from `employee` T1
WHERE T1.Supervisor_ID = '".$id."')
OR Employee_ID IN (
SELECT T2.Manager_ID from `branches` T2
WHERE T2.Manager_ID = '".$id."')
OR Employee_ID = '".$id."'
But when I add this: DATE(Timestamp) = DATE_ADD(CURDATE(), INTERVAL 24 HOUR) in the statement to filter the date the only records shown are coming from this: OR Employee_ID = '".$id."'
SELECT * FROM `report` WHERE DATE(`Timestamp`) = DATE_ADD(CURDATE(), INTERVAL 24 HOUR) AND Employee_ID IN (
SELECT T1.Employee_ID from `employee` T1
WHERE T1.Supervisor_ID = '".$id."')
OR Employee_ID IN (
SELECT T2.Manager_ID from `branches` T2
WHERE T2.Manager_ID = '".$id."')
OR Employee_ID = '".$id."'
I want my modified SQL statement to be filtered by today's date, week, month, and past 3 months. I already have to code for those filters but I cannot figure out how to add those to my statement.