Hi
I am trying to do a query which is pretty straightforward but I'm having real problems getting the correct results.
Just to quickly surmise the problem I have an 'employees' table with a unique ID, a 'reports' table with a unique ID and also a lookup table which links the two together.
It looks like this
'employees'
ID Name
1 Smith
2 Jones
'reports'
ID ReportName
1 Starting Certificate
2 Leaving Certificate
'lk_employees_reports'
ID fk_employees_id fk_reports_id DateProduced
1 1 2 01SEP2004
2 1 1 02SEP2004
3 2 2 03SEP2004
Each time a report is printed a record is inserted into 'lk_employees_reports'.
I need to select all employees from the 'employee' table and include the DateProduced field if there is an entry for the specific reportID.
So if the selected ReportID is 1 it shows all employees and includes the DateProduced fields for employee 1 in this example.
I have tried loads of different joins and things and cannot get all employees back (just once) and include the DateProduced when appropriate.
Any help much appreciated.
Thanks
I am trying to do a query which is pretty straightforward but I'm having real problems getting the correct results.
Just to quickly surmise the problem I have an 'employees' table with a unique ID, a 'reports' table with a unique ID and also a lookup table which links the two together.
It looks like this
'employees'
ID Name
1 Smith
2 Jones
'reports'
ID ReportName
1 Starting Certificate
2 Leaving Certificate
'lk_employees_reports'
ID fk_employees_id fk_reports_id DateProduced
1 1 2 01SEP2004
2 1 1 02SEP2004
3 2 2 03SEP2004
Each time a report is printed a record is inserted into 'lk_employees_reports'.
I need to select all employees from the 'employee' table and include the DateProduced field if there is an entry for the specific reportID.
So if the selected ReportID is 1 it shows all employees and includes the DateProduced fields for employee 1 in this example.
I have tried loads of different joins and things and cannot get all employees back (just once) and include the DateProduced when appropriate.
Any help much appreciated.
Thanks