0

I have 3 tables that I am trying to combine into one with a query. One table"Main" has the primary key "AppID" and the other two tables "Net & Env" uses this key as a foreign key. What I am trying to do is make a join on the Main and Net AppID, for every appid that exist in Net and also for every Appid that exist in Env. My idea is that if I do a join on the Main and Net, then the only thing left is the AppIds in sync, but I want to also do the join from Main to Env. My query is:

SELECT Main.Name FROM ((Main INNER JOIN Net On Main.AppID=Net.AppID)INNER JOIN 
Env On Env.AppID=Main.AppID);

Do I need to have a subquery for the outer join. I know that the abover query is not giving me my desire results. Let me know if my question is unclear.

1 Answer 1

2

Use a LEFT JOIN

SELECT m.Name FROM Main m LEFT JOIN Net n ON n.AppID=m.AppID LEFT JOIN Env e ON e.AppID=m.AppID;
Sign up to request clarification or add additional context in comments.

1 Comment

@Jake nobody is an idiot, or perhaps only someone that don't ask ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.