Hi,
This isn't really an access question, but as I'm really new to SQL I
don't know where I would post this. Any suggestions on that would
also be helpful. Now on to the question...
I am trying to extract data from a Timberline database through an OBDC
driver to MS Excel. I'm using Microsoft Query and a crude knowledge
of SQL to build my query.
What I'm having trouble doing is getting a list of jobs (or rather,
job numbers) and the appropriate contact for those jobs.
I'd like to get a list of jobs and the primary contact for that job.
That is, if a job has a contact of type A, I want the result set to
show that contact next to the job, if not, I want a contact of type B,
if finally not that, I want a contact of type C.
I was hoping that a union statement could help me with that.
Something along the lines of:
SELECT JOB_LIST.Job, CONTACT_LIST.Name
FROM JOB_LIST, CONTACT_LIST
WHERE (JOB_LIST.Contact_ID = CONTACT_LIST.Contact_ID)
AND (CONTACT_LIST.Type = 'A')
UNION
SELECT JOB_LIST.Job, CONTACT_LIST.Name
FROM JOB_LIST, CONTACT_LIST
WHERE (JOB_LIST.Contact_ID = CONTACT_LIST.Contact_ID)
AND (CONTACT_LIST.Type = 'B')
However, this gets a "non unique table reference" error. The UNION
statements I've seen generally form a union between select statements
from two different databases, not between select statements from the
same database. However, maybe the SQL code here looks good, and the
problem lies within Microsoft query and I should ask this somewhere
else; I really don't know.
Is there a way to do what I want? Does it have nothing to with UNION
statements?
Any help would be greatly appreciated,
Chip
[Please reply to message board, not e-mail]