Assume a table of 100K Canadian postal code prefixes with population sizes:
| Region code | Population |
|---|---|
| H2 | 10,000,000 |
| H2Z | 100,000 |
| H2K | 50,000 |
| H2Z 1G9 | 500 |
Given a full length postal code, e.g. "H2Z 1G9" I need to return every row whose region code is a prefix of the input. For some reason I need to do this a lot, so I need effective indexing.
How should I go about this?
UNION ALLof the respective results.