I have two tables employee and time. Both contain the common field EMPNO.
I want to link the tables on the EMPNO and find all records within a specific date range. But I also want to include any employee who has no time records in the time file.
note - my tables are setup to have "not null" values in the table columns. The default value is ''
here are my attempts to construct the select statement to no avail
I only get the records that are within the date range and not the employees with no records in the time file.
I can get all records from the time file and the employees with no time records like this. (but that is no good because it includes time records outside the date range)
I want to link the tables on the EMPNO and find all records within a specific date range. But I also want to include any employee who has no time records in the time file.
note - my tables are setup to have "not null" values in the table columns. The default value is ''
here are my attempts to construct the select statement to no avail
Code:
select e.*, t.* from employee e left join time t on e.empno = t.empno where (t.workday >= '20090208' and t.workday <= '20090214') or t.empno = ''
I can get all records from the time file and the employees with no time records like this. (but that is no good because it includes time records outside the date range)
Code:
select e.*, t.* from employee e right join time t on e.empno = t.empno
Comment