3
I need to make a comparison between two tables to find out if the address of table A is present in table B.
Example: Table A has a record with the ENDERECO field with the value "RUA FULANO DE TAL 67 401" and in Table B, the ENDERECO field has "RUA FULANO DE TAL, AP 401, 67". That is, it contains everything I seek, but in a different order. SQL
SELECT * FROM TABELA_B WHERE ENDERECO LIKE '%RUA%FULANO%DE%TAL%67%401%'
does not return anything, because SELECT looks for the parameters in the informed order.
Now for my question: There is a way to search for all parameters, regardless of the order they were entered?
What you’re trying to do is extremely difficult. There are companies that market (and it is not cheap) routines for normalizing addresses, which take equal addresses, but written differently (abbreviations, position of number, complement, etc.) and transform into a single model, normalized, which can be compared by equality, or by percentage of similarity. In short, it is not a simple implementation. The solution given by Bacco, based on the simple algorithm you are implementing, will work, but do not expect very satisfactory results!
– Loudenvier