Assuming a Postgres Table containing zip as varchar(10) I want to get either all results matching a specific zip or extend my results with entries close to the queried one in case there are not enough results. Say:
A user searches for zip “56500” and my result-set returns 2 items running an exact match. In this case I want to perform a kind of like query that finds “565%” entries. Eventually I need to run this in one query.
Any suggestions?
Something like this might be what you want:
This may not be the most efficient solution, but at least it is a single query so might do well as a starting point.