2
I’m trying to make a query where the data lies in 4 tables:
TAFCBHISTPED = NUPED, DTEMIS
TAFGRPROD = CDGRPR, DSGRPR
TAFPROD = CDPROD, CDGRPR
TAFITHISTPED = NUPED, CDPROD, QTPED
My query stayed that way:
SELECT
TAFCBHISTPED.NUPED,
TAFCBHISTPED.DTEMIS,
TAFGRPROD.CDGRPR,
TAFGRPROD.DSGRPR,
TAFPROD.CDPROD,
TAFPROD.CDGRPR,
TAFITHISTPED.NUPED,
TAFITHISTPED.CDPROD,
TAFITHISTPED.QTPED
FROM dbo.TAFCBHISTPED
INNER JOIN dbo.TAFITHISTPED ON TAFCBHISTPED.NUPED = TAFITHISTPED.NUPED
LEFT JOIN dbo.TAFPROD ON TAFGRPROD.CDGRPR = TAFPROD.CDGRPR
But I get the following error:
Sqlstate: 42000 Error Code: 4104 Message: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]The multi-part identifier "TAFGRPROD.CDGRPR" cannot be associated.
I haven’t seen how I could do it yet. Could you show me how?
– Bruno Queiroz
Basicamente TAFGRPROD.CDGRPR é chave estrangeira da tabela TAFPROD, TAFCBHISTPED.NUPED e TAFPROD.CDPROD são chaves estrangeiras da tabela TAFITHISTPED.
– Bruno Queiroz
See if my answer helps you.
– Caique Romero