troubleshooting Question

SQL Query - Full Join

Avatar of holemania
holemania asked on
SQL
7 Comments2 Solutions390 ViewsLast Modified:
I have a SQL query that joins another select statement.  If the main query is null, I still want to pull from the nested query.  Is this even possible or would I need to create 2 temp table and do that?

Example:

SELECT E.ID, E.NAME, E.DEPT_ID, A.DEPT_DESC, E.PAYRATE FROM EMPLOYEE E
FULL OUTER JOIN
(SELECT D.DEPT_ID, D.DEPT_DESC FROM DEPT D) A ON A.DEPT_ID = E.DEPT_ID

Output:

2912      Joe Smuack      122     MIS     $22.00
NULL     NULL                NULL   FIN     NULL
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 2 Answers and 7 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros