yo iris, ClimbingMonkey’s on the right track. heres a tweak:
SELECT er.document_name, ei.employee_name
FROM employee_records er
JOIN employee_info ei ON er.employee_id = ei.employee_id
WHERE er.record_date >= DATE_SUB(CURDATE(), INTERVAL 1 DAY);
hey iris72! your query looks interesting, but there’s a few things to tweak. have you considered using INNER JOIN like this:
SELECT er.document_name, ei.employee_name
FROM employee_records er
INNER JOIN employee_info ei ON er.employee_id = ei.employee_id
WHERE er.record_date >= DATE_SUB(CURDATE(), INTERVAL 1 DAY);
this should give you what you need. what do you think? any other challenges youre facing with the query?
I’ve encountered similar issues before, and here’s a solution that should work for you:
SELECT er.document_name, ei.employee_name
FROM employee_records er
INNER JOIN employee_info ei ON er.employee_id = ei.employee_id
WHERE er.record_date >= DATE_SUB(CURRENT_DATE(), INTERVAL 1 DAY)
AND er.record_date <= CURRENT_DATE();
This query uses INNER JOIN to combine the tables based on employee_id. The WHERE clause filters records for today and yesterday using DATE_SUB and CURRENT_DATE functions. This approach is more reliable and efficient than using string comparisons. Let me know if you need any clarification on this solution.