troubleshooting Question

Join 2 tables and show everything from left table.

Avatar of corey gashlin
corey gashlin asked on
Microsoft SQL Server
4 Comments1 Solution60 ViewsLast Modified:
I have 2 tables I am trying to join. i have tried joining but it is not working how I would like.

Table 1 - OCI_DISCIPLINES - Shows as below -
discipline
Mechanical
Electrical
Plumbing
Fire Protection
Cx
Low Voltage
Report
Study
CAD
BIM

Table 2 - OCI_VOODOO Shows as below

Department      proj_id      timing
CAD      2147      21h 0m
Cx      2147      73h 20m
Electrical      2147      40h 30m
Mechanical      2147      88h 30m
Plumbing      2147      42h 0m

Trying to get Table1 to show all the rows for disciplines and join up to table 2.

Result I am looking for is this.

Department      proj_id      timing
CAD      2147      21h 0m
Cx      2147      73h 20m
Electrical      2147      40h 30m
Mechanical      2147      88h 30m
Plumbing      2147      42h 0m
Low Voltage 2147        0
Study          2147           0
Fire Protection 2147     0


SELECT        dbo.OCI_DISCIPLINES.discipline, dbo.OCI_VOODOO.proj_id, dbo.OCI_VOODOO.timing, dbo.OCI_DISCIPLINES.id
FROM            dbo.OCI_DISCIPLINES LEFT OUTER JOIN
                         dbo.OCI_VOODOO ON dbo.OCI_DISCIPLINES.discipline = dbo.OCI_VOODOO.Department  Where OCI_VOODOO.proj_id=2147


This is waht I made and it not working.
ASKER CERTIFIED SOLUTION
ste5an
Senior Developer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
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 1 Answer and 4 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