1

I have two tables that look as such:

Table1               Table2
ID | Appname         ID  | App  | Dependency
------------         -----------------------
1  | App1            1   | 2    |  3
2  | App2            2   | 3    |  1
3  | App3            3   | 2    |  1
etc....               etc...

Basically an application can have one or more dependencies that must be complete prior to executing. In Table2, both App and Dependency relates to the ID field of Table1, but I'm having a difficult time linking these together with SQL without getting errors.

What is the correct way to join the tables so that I get results that look like this:

Dependencies:
App2: App3, App1
App3: App1

(doesn't have to be laid out like that, but if it can be, that would be great)

1

Use view designer, add Table2, then add Table1 two times.

Select Table1.ID and drag till Table2.App and do the same with Table1_1 and Table2.Dependency.

SELECT Table2.Id, 
       Table2.App, 
       Table2.Dependency, 
       Table1.Appname, 
       Table1_1.Appname
FROM 
       Table1 AS Table1_1 
INNER JOIN 
       (Table1 INNER JOIN Table2 ON Table1.Id = Table2.AppId) 
       ON Table1_1.Id = Table2.Dependency;
2
  • Thanks, I'll try that. It didn't occur to me that I could have multiple instances of Table1 in the design view. Was trying to connect both references to Table1 to the same instance. – Tim S. Feb 23 '17 at 13:47
  • I'm glad to be able to help. – McNets Feb 25 '17 at 1:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.