troubleshooting Question

Sql Server query to left join

Avatar of Sam OZ
Sam OZFlag for Australia asked on
DatabasesMicrosoft SQL ServerSQL
2 Comments1 Solution75 ViewsLast Modified:
I have an Sql Server 2016 Database with tables TB_Cable,   TB_Item, TB_Connection

Samples data below  ( There are more fileds on each table)
TB_Cable
Cable_ID     Cable_Num    CableLoc
  C1                Cable1             123,St
  C2                 Cable2             345,St
  C3                 Cable3             456,St


TB_Items
 Item_ID            ItemName
    I1                        Item1
    I2                        Item2
    I3                        Item3

TB_Connection
  Cable_ID    Item_ID
    C1                  I1
    C2                  I3

I am looking for the query to give result as follows
Result of query   ( Has all cable . Lists Items when Cable is connected.  For other cables just "Vacant" is displayed for Item
Cable&Connection
-----------------------
   CableNum    CableLoc   ItemName
      Cable1          123,St       Item1
      Cable2          345,st        Item2
      Cable3           456,St       Vacant
ASKER CERTIFIED SOLUTION
Andrei Fomitchev
Sr. DBA

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 2 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 2 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