Redirect Based on Data

I have two types of searches that I want a route to handle. If I get a result for the first query I want to redirect to another page, if it doesn’t I want to execute the second query and display the result. How do I do this?