Don't run extra queries when running LOOKUP queries with wildcards

Fixes #452