INNER JOIN WITH 3 TABLES

  • Thread starter rdemyan via AccessMonster.com
  • Start date
R

rdemyan via AccessMonster.com

I'm trying to create an SQL Statement in code:

So far I have the following:

SELECT A.MASTER_PROJECT_ID, B.SITE
FROM [MASTER_TABLE] AS A, INNER JOIN [CONSTRUCTION_TABLE] AS B
ON A.MASTER_PROJECT_ID = B.PROJECT_ID OR A.SUB_PROJECT_ID = B.PROJECT_ID
WHERE SITE IN ('BOSTON')

This works fine and produces the expected results.

However, now I would like to add a third table that provides the PROJECT_NAME
to match up with the selected MASTER_PROJECT. As you might expect
MASTER_PROJECT is a number which is meaningless to most people. PROJECT_NAME
is a short description of the project.

I can't seem to get this to work.

The table name that contains PROJECT_NAME is [PROJECT_TABLE] As C and the key
for this table is PROJECT_ID. So something where C.PROJECT_ID = A.
MASTER_PROJECT_ID.

Thanks for any help.
 
R

rdemyan via AccessMonster.com

It looks like I have a comma where it shouldn't be. Second line should be:

FROM [MASTER_TABLE] AS A INNER JOIN [CONSTRUCTION_TABLE] AS B

I'm trying to create an SQL Statement in code:

So far I have the following:

SELECT A.MASTER_PROJECT_ID, B.SITE
FROM [MASTER_TABLE] AS A, INNER JOIN [CONSTRUCTION_TABLE] AS B
ON A.MASTER_PROJECT_ID = B.PROJECT_ID OR A.SUB_PROJECT_ID = B.PROJECT_ID
WHERE SITE IN ('BOSTON')

This works fine and produces the expected results.

However, now I would like to add a third table that provides the PROJECT_NAME
to match up with the selected MASTER_PROJECT. As you might expect
MASTER_PROJECT is a number which is meaningless to most people. PROJECT_NAME
is a short description of the project.

I can't seem to get this to work.

The table name that contains PROJECT_NAME is [PROJECT_TABLE] As C and the key
for this table is PROJECT_ID. So something where C.PROJECT_ID = A.
MASTER_PROJECT_ID.

Thanks for any help.
 
R

rdemyan via AccessMonster.com

No need to respond. I gave up and essentially used a couple of queries to
accomplish the task.
It looks like I have a comma where it shouldn't be. Second line should be:

FROM [MASTER_TABLE] AS A INNER JOIN [CONSTRUCTION_TABLE] AS B
I'm trying to create an SQL Statement in code:
[quoted text clipped - 19 lines]
Thanks for any help.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top