Although the actual schema is a bit more complex, the following should be a bit easier for me to get across.
In one table I have a list of jobs:
Job Status Open date Close date 1 Closed 04/29/2009 04/30/2009 2 Open 04/30/2009 3 Open 04/30/2009
..and in another I have a list of notes associated with the jobs:
ID Job Type Date Text 1 1 Open 04/29/2009 Please fix my printer 2 1 Close 04/30/2009 Printer fixed 3 2 Open 04/30/2009 Please fix my monitor 4 2 Update 04/30/2009 Part required 5 3 Open 05/01/2009 Please fix my mouse
Each job will have an "Open" note, optionally one or more "Update" notes, and optionally a "Close" note. There is obviously a one-many relationship on the Job field.
What I'd like to have is a single query that returns a list of jobs, open date, opening note and, if present, closing note, like this:
Job Status Open date Open note Close note 1 Closed 04/29/2009 Please fix my printer Printer fixed 2 Open 04/30/2009 Please fix my monitor 3 Open 04/30/2009 Please fix my mouse
My attempts at doing this always fail because I end up with the following:
Job Status Open date Open note Close note 1 Closed 04/29/2009 Please fix my printer 1 Closed 04/29/2009 Printer fixed 2 Open 04/30/2009 Please fix my monitor 2 Open 04/30/2009 3 Open 05/01/2009 Please fix my mouse 3 Open 05/01/2009
..or:
Job Status Open date Open note Close note 1 Closed 04/29/2009 Please fix my printer 1 Closed 04/29/2009 Printer fixed 2 Open 04/30/2009 Please fix my monitor 3 Open 05/01/2009 Please fix my mouse
I'm using SQL in Access 2003 and although the eventual query will be from an Excel front-end via ADO, I'm only trying to get this working from within Access at the moment.