当前位置: 动力学知识库 > 问答 > 编程问答 >

sql server - how does self-join work? (ms sql)

问题描述:

how/why would the result set of this: (returns 1215 records)

SELECT UM2.UCN_Group, UM2.UCN, UM2.Cust_EDP

FROM CleanRoom.dbo.UCN_Master AS UM

JOIN CleanRoom.dbo.UCN_Master AS UM2

ON UM.UCN_Group = UM2.UCN_Group

WHERE UM.UCN_Group NOT LIKE 'EXPN%'

be different from this: (returns 1203 records)

SELECT UM2.UCN_Group, UM2.UCN, UM2.Cust_EDP

FROM CleanRoom.dbo.UCN_Master AS UM2

WHERE UM2.UCN_Group NOT LIKE 'EXPN%'

shouldn't the JOIN condition on the first query ensure same result set from both queries? TIA

网友答案:

I can see the only reason for this: you've got rows with identical UCN_Group values.

分享给朋友:
您可能感兴趣的文章:
随机阅读: