How do I get a nested query to only display content that the main query outputed

How do I get a nested query to only display content that the main query outputed