0
I have two tables:
Tabela1 Tabela2
+------+----------+--------+ +------+----------+------------+
| id | idCidade | bairro | | id | idBairro | logradouro |
+------+----------+--------+ +------+----------+------------+
| 6091 | 15890 | Vila A | | 05 | 6091 | Av. Brasil |
| 5089 | 17500 | Vila A | | 08 | 1000 | Av. Brasil |
+------+----------+--------+ +------+----------+------------+
The user will inform the 'street', 'idCidade'. I need to know which neighborhood is a given street in a given city. With the name of the 'street' I search in Tabela2, in the example above it returns to me the existence of two places with this name in destintos neighborhoods. But I also do a search in Tabela1, I search the 'id' of all neighborhoods of a given city. If for example I inform that (idCidade=17500) and (logradouro=Av Brasil), the neighborhood of this street would be 'Vila A' of id=5089. What query would you use for this?
Your example is not valid, since the
idBairro
of the second patio ofTabela1
is 1000 and has no record with this value inTabela1
– Sorack
@Sorack a
Av. Brasil
can pass through several neighborhood, note : he passed an example, not real case.– Guilherme Lautert