Convert uuid lookup query into subquery.