Please try this one List<TopicAssignment> ta = [SELECT EntityId FROM TopicAssignment WHERE TopicId = '0TO30000000Xea1GAC']; System.Debug(ta); List<Id> fiList = new List<Id>(); for (TopicAssignment t: ta) { fiList.add( t.EntityId ); } List<CollaborationGroupFeed> cgf = [select ParentId from CollaborationGroupFeed WHERE ParentId = '0F936000000cWkMCAU']; System.Debug(cgf); List<Id> piList = new List<Id>(); for (CollaborationGroupFeed: cgf ) { piList.add( c.ParentId ); } List<FeedItem> chatFeed = [SELECT Id, Body, CommentCount, CreatedDate, LikeCount, LinkUrl, ParentId, RelatedRecordId, Title, Type, (SELECT Id, CommentBody, CreatedDate, CreatedById, FeedItemId, ParentId FROM FeedComments) FROM FeedItem WHERE (Id IN :fiList OR ParentId in :piList) AND CreatedDate >= 2015-12-15T00:00:00Z]; You could use list of SObject only if this is the same SObject. So, if you do List<FeedItem> feedItems = [SELECT Id FROM FeedItem WHERE Id IN: fiList ]; you could use either WHERE (Id IN :fiList) or WHERE (Id IN :feedItems ) However, since SObject types are different, you can't put WHERE (Id IN :cgf ) because here either List of Id is expected or List of FeedItem (which Salesforce can automatically transform to List of Id ) but List of TopicAssignment is not. Because there might be ambiguity if there were two different lookups to FeedItem then it won't be clear which one should be taken.