SQL - How to override ambiguous external junction?

Asked

Viewed 314 times

1

I’m trying to normalize a database for addresses and zip codes. However, there is a situation in which the Post Office assigns, for the same street, a ZIP code to the side with even numbers and the other to the side with odd numbers, and another in which the streets are divided and, for each division, one CEP for the side with even numbers and the other for the side with odd numbers. As there is side in both cases, I created a single table, registering "even side" and "odd side". The problem (ambiguous external junction) appeared when I tried to connect the two types of streets to this single Lado table, because the bank probably does not know which instruction to carry out first, since the two need information from the Lado table. Below the illustrative figure:

inserir a descrição da imagem aqui

Therefore, there is a way to eliminate this "ambiguous external junction" error without having to repeat the Side table ?

Thanks.

  • The diagram didn’t help me much to understand the problem, it would be interesting to explain it and also add the SQL query you are trying to do. Also consider that the ambiguity may come from not specifying in the SQL query the table name before the column idLado, for example LogradouroLado.idLado instead of just idLado.

1 answer

2

Ambiguity may be because in the SQL query you are using only idLado instead of NomeDaTabela.idLado. For example, instead of...

select (...) where idLado = 1

...you should do...

select (...) where LogradouroLado.idLado = 1

...or call the table for example from LogradouroLado as t1 and make t1.idLado. Got the idea?

That one as is optional.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.