I created a new response because it took a completely different approach.
I checked the database you are using and with two queries you can return the ZIP code's address.
A query to find out what status the zip code is
Another query to find out what city and street is.
Step 1
-- Exemplo: CEP 97060-003
SELECT
uf.UF,
uf.Nome
FROM uf
WHERE "97060" BETWEEN uf.Cep1 AND uf.Cep2;
+----+-------------------+
| uf | Nome |
+----+-------------------+
| RS | Rio Grande do Sul |
+----+-------------------+
Step 2
Save the UF field to a variable and do the next search
-- Exemplo: CEP 97060-003
SELECT *
FROM rs as uf
WHERE uf.cep = "97060-003"
+-------+-------------+--------------------------+--------+-----------+---------------+
| id | cidade | logradouro | bairro | cep | tp_logradouro |
+-------+-------------+--------------------------+--------+-----------+---------------+
| 20410 | Santa Maria | Nossa Senhora Medianeira | Centro | 97060-003 | Avenida |
+-------+-------------+--------------------------+--------+-----------+---------------+
I do not know what language you're programming in, but it's very simple.
The first search is done with the first 5 digits (% with%).
While the second is done with all the digits and with the hyphen ( 99999
).