0
I have two tables and need to unite them bringing the result through the following conditions:
The Numero_tel_origem
and Numero_tel_dest
table 1, has to be the same Numero_tel_origem
Numero_tel_dest
of Table 2.
Ex.:
Tabela 1
Numero_tel_origem = 000001
Numero tel_dest = 10000
Tabela 2
Numero_tel_origem = 000001
Numero tel_dest = 10000
It needs to be true the two conditions that are in the same row of the tables.
How can I do Join?
select * from tabela1 a
inner join tabela2 b on a.Numero_tel_origem = b.Numero_tel_origem AND a.Numero_tel_dest = b.Numero_tel_dest
This example didn’t work of John you put up didn’t work?
– Daniel Mendes
No, pq first it validates if the numero_tel_origin is the same in the two tables and then validate the numero_tel_dest. I need the validation to occur at the same time. ...
– lboniotti
So does the source number have to be equal between the two tables or does the destination number have to be equal? In their form, both need to be equal, is that a rule or if one condition meets the other need not be checked? If so, you should not use an AND, you should use an OR.
– Daniel Mendes
Both need to be the same... for example: I made 3 calls during the day for you and two different people (table 2), in table 1 there are 3 links for you. I need to bring from table 2 just the call I made to you.
– lboniotti
It makes no sense for you to speak in order of evaluation, "first validates .. and then validates ...". With the AND operator the two clauses need to be satisfied, regardless of the order in which they are assessed.
– anonimo