GARANTIR DESCONTO

Fórum Ligar tabelas com inner join #507225

14/01/2015

0

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
Welison

Welison

Responder

Post mais votado

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 

Ronaldo Lanhellas

Ronaldo Lanhellas
Responder

Gostei + 1

Mais Posts

14/01/2015

Wander Santos

http://www.mysqltutorial.org/mysql-inner-join.aspx

www.youtube.com/watch?v=C_OpAzDImfI
Responder

Gostei + 0

14/01/2015

Ronaldo Lanhellas

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 

Responder

Gostei + 0

14/01/2015

Welison

De onde é esse tb1, tb2 e tb3???
Responder

Gostei + 0

14/01/2015

Ronaldo Lanhellas

De onde é esse tb1, tb2 e tb3???


São alias para suas tabelas.
Responder

Gostei + 1

14/01/2015

Welison

BLZ
DEU CERTO
OBRIGADO
Responder

Gostei + 0

14/01/2015

Ronaldo Lanhellas

BLZ
DEU CERTO
OBRIGADO


De nada, disponha.
Responder

Gostei + 0

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar