this is subtle, but you need to change this --
Code:
LEFT OUTER
JOIN dbo.Attribute_Values
ON dbo.Items.Id = dbo.Attribute_Values.Object_Id
WHERE dbo.Items.Is_Set = 0
AND dbo.Items.Status = 2
AND dbo.Folder_Contents.Folder_Id = 'C6E34BD2-F294-4471-BB27-AD83BD4C46DF'
AND dbo.Attribute_Values.Attribute_Id = '3FEE30CF-99DC-4C15-84D3-7191C8B13F69'
to this --
Code:
LEFT OUTER
JOIN dbo.Attribute_Values
ON dbo.Items.Id = dbo.Attribute_Values.Object_Id
AND dbo.Attribute_Values.Attribute_Id = '3FEE30CF-99DC-4C15-84D3-7191C8B13F69'
WHERE dbo.Items.Is_Set = 0
AND dbo.Items.Status = 2
AND dbo.Folder_Contents.Folder_Id = 'C6E34BD2-F294-4471-BB27-AD83BD4C46DF'
with the condition in the WHERE clause, the left outer join is executed, and the dbo.Attribute_Values row,
whether it has that Attribute_Id value or not, is returned by the join, but then the WHERE condition is applied, and for unmatched rows, the Attribute_Id value, which is NULL, which does not equal the specified value, so that row is eliminated, in effect returning the same results as if it were an inner join
on the other hand, with the condition in the ON clause, it becomes a condition of the join, so if there's isn't a matching dbo.Attribute_Values row
with the specified Attribute_ID value, then you have an unmatched condition, in which case you still get the item
it will make sense after you look at it a few times, trust me
