Take this example query:
INSERT INTO #QueryOutput
SELECT DISTINCT
UR2.LeftID, UR3.LeftID
FROM
UserRelations UR1
JOIN
UserRelations UR2 ON UR1.RightID = UR2.LeftID
JOIN
UserRelations UR3 ON UR2.RightID = UR3.LeftID
WHERE
(UR1.RelationID = 1)
OR (UR1.RelationID = 1 AND UR2.RelationID = 1)
AND UR1.LeftID IN (SELECT UserID FROM #QueryInput)
With this being the magic row:
INSERT INTO #QueryOutput SELECT DISTINCT UR2.LeftID ,UR3.LeftID
#QueryOutput is a table with a single column, UserID
I want to insert UR2.LeftID, UR3.LeftID, or as many UR*.LeftID's I have in that single column. How do go about doing that?
Thanks
WHERE UR1.RelationID = 1with same results. It's becauseX ∨ X ∧ whatever ≡ X. Something may be missing in the query's logic (or in the version you've posted here).