Fix grammar to not allow joining queries inside subquery