Avatar of Sam OZ
Sam OZ
Flag for Australia

asked on 

Sql Server query to left join

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
DatabasesMicrosoft SQL ServerSQL

Avatar of undefined
Last Comment
Sam OZ

8/22/2022 - Mon