Why is my left join not returning nulls?

后端 未结 6 1428
半阙折子戏
半阙折子戏 2020-12-05 18:31

In sql server 2008, I have the following query:

select      
    c.title as categorytitle,
    s.title as subcategorytitle,
    i.title as itemtitle
from cat         


        
6条回答
  •  渐次进展
    2020-12-05 18:48

    Maybe this join also should be a left join?

    join items i on ic.itemid = i.itemid and i.siteid = 132
    

    EDIT:

    Now you are selecting only existing site ids in the where clause:

    i.siteid = 132
    

    It should allow null values, try something like this:

    (i.siteid = 132 or i.siteid is null)
    

    or you could move i.siteid = 132 back to the join condition

提交回复
热议问题