2つの簡単なクエリを次に示します。
SELECT EntityID, EntityName FROM EntityRelations.Entities
WHERE EntityID IN (SELECT ModifiedByEntityID FROM EntityRelations.AssistanceFlags af WITH (nolock)
JOIN EntityRelations.Entities et WITH (nolock) ON af.EntityId = et.EntityId
WHERE ModifiedDate BETWEEN '6/1/12 3:00 AM'
AND '8/1/12 2:59 AM')
SELECT EntityName, Note, ModifiedByEntityID, ModifiedDate FROM EntityRelations.AssistanceFlags af WITH (nolock)
JOIN EntityRelations.Entities et WITH (nolock) ON af.EntityId = et.EntityId
WHERE ModifiedDate BETWEEN '6/1/12 3:00 AM'
AND '8/1/12 2:59 AM'
ORDER BY ModifiedDate ASC
1つ目は、ModifiedByEntityIDフィールドへの2つ目のクエリに挿入したい名前の小さなテーブルを示し、番号の代わりに名前が表示されます。