2
I’m having a hard time getting just the zip code of a field where address data is not atomic, would like to know a way using Mysql to get only the 8 numeric values of the ZIP code snippet from the field of all base records that contain 8 successive digits and if possible considering the cases where there is a tab hyphen (-) but bringing only the numbers as a result of the selection.
Typical values in the table of interest field: (address field data)
BR-50670901 Recife, PE, Brazil.
BR-70910900 Brasilia, DF, Brazil.
BR-14040901 Ribeirao Preto, SP, Brazil.
BR-74001970 Goiania, Go, Brazil.
Nucleo Fis Aplicada, BR-70919970 Brasilia, DF, Brazil.
F-35042 Rennes, France.
Dept Matemat, BR-13083970 Campinas, SP, Brazil.
Rochester, NY 14627 USA.
Cambridge CB3 9EW, England.
Regex will not be the solution, since in Mysql it only serves to "match" field with a certain value, not to extract that value from the field. If it was only from Brazil until it was possible, but with this data, I do not know.
– bfavaretto
I only need the Brazilian zip code yes! 8 digits.
– Igoto
You select normally, and then just cut the string programmatically.
– Jorge B.
It has to be done on Workbench, only using SQL.
– Igoto