Ligar tabelas com inner join
Preciso ligar essas tres tabelas com inner join! ajuda??
select numeronf, valorcontabil
from LCTOFISENT
where chavelctofisent = 493
and codigoempresa = 465
and numeronf = 231
select codigocfop,valorcontabilimposto,outrasimposto
from LCTOFISENTCFOP
where chavelctofisent =493
and codigoempresa = 465
select codigoproduto,valortotal,isentasicms,outrasicms,valoripi
from LCTOFISENTPRODUTO
where chavelctofisent = 493
and codigoempresa = 465
select numeronf, valorcontabil
from LCTOFISENT
where chavelctofisent = 493
and codigoempresa = 465
and numeronf = 231
select codigocfop,valorcontabilimposto,outrasimposto
from LCTOFISENTCFOP
where chavelctofisent =493
and codigoempresa = 465
select codigoproduto,valortotal,isentasicms,outrasicms,valoripi
from LCTOFISENTPRODUTO
where chavelctofisent = 493
and codigoempresa = 465
Welison
Curtidas 0
Melhor post
Ronaldo Lanhellas
14/01/2015
Faça assim:
select tb1.numeronf, tb1.valorcontabil, tb2.codigocfop,tb2.valorcontabilimposto,tb2.outrasimposto, tb3.codigoproduto,tb3.valortotal,tb3.isentasicms,tb3.outrasicms,tb3.valoripi from LCTOFISENT tb1 INNER JOIN LCTOFISENTCFOP tb2 ON (tb1.chavelctofisent = tb2.chavelctofisent AND tb1.codigoempresa = tb2.codigoempresa) INNER JOIN LCTOFISENTPRODUTO tb3 ON (tb1.chavelctofisent = tb3.chavelctofisent AND tb1.codigoempresa = tb3.codigoempresa) where tb1.chavelctofisent = 493 and tb1.codigoempresa = 465 and tb.1numeronf = 231
GOSTEI 1
Mais Respostas
Wander Santos
14/01/2015
http://www.mysqltutorial.org/mysql-inner-join.aspx
www.youtube.com/watch?v=C_OpAzDImfI
www.youtube.com/watch?v=C_OpAzDImfI
GOSTEI 0
Ronaldo Lanhellas
14/01/2015
Faça assim:
select tb1.numeronf, tb1.valorcontabil, tb2.codigocfop,tb2.valorcontabilimposto,tb2.outrasimposto, tb3.codigoproduto,tb3.valortotal,tb3.isentasicms,tb3.outrasicms,tb3.valoripi from LCTOFISENT tb1 INNER JOIN LCTOFISENTCFOP tb2 ON (tb1.chavelctofisent = tb2.chavelctofisent AND tb1.codigoempresa = tb2.codigoempresa) INNER JOIN LCTOFISENTPRODUTO tb3 ON (tb1.chavelctofisent = tb3.chavelctofisent AND tb1.codigoempresa = tb3.codigoempresa) where tb1.chavelctofisent = 493 and tb1.codigoempresa = 465 and tb.1numeronf = 231
GOSTEI 0
Welison
14/01/2015
De onde é esse tb1, tb2 e tb3???
GOSTEI 0
Ronaldo Lanhellas
14/01/2015
De onde é esse tb1, tb2 e tb3???
São alias para suas tabelas.
GOSTEI 1
Welison
14/01/2015
BLZ
DEU CERTO
OBRIGADO
DEU CERTO
OBRIGADO
GOSTEI 0
Ronaldo Lanhellas
14/01/2015
BLZ
DEU CERTO
OBRIGADO
DEU CERTO
OBRIGADO
De nada, disponha.
GOSTEI 0