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)
Cable_ID     Cable_Num    CableLoc
  C1                Cable1             123,St
  C2                 Cable2             345,St
  C3                 Cable3             456,St

 Item_ID            ItemName
    I1                        Item1
    I2                        Item2
    I3                        Item3

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