0
Good afternoon, I will try to explain a situation where I am, I have 3 tables(A,B,C) where A and B are directly related, B and C are also related. I need to get the value of a field in table C where I am consulted data in table A. I tried to do it this way but the result came null:
SELECT h.Id, h.TagHistorian, h.Descricao, um.Sigla ,h.ComentarioHistoria,
(SELECT plc.TipoVariavel_Id FROM plc WHERE h.Id = plc.Id) AS varplc
FROM historian h
INNER JOIN um ON um.Id = h.UM_Id
INNER JOIN tipovariavel tp ON tp.Id = h.TipoVariavel_Id
Lowers the structure of the tables:
Basically I need to get the description of the "Typovariavel" and the query will be in the table "Historian" which is related to the table "PLC".
Maybe it was just a transcription error but, according to its figure, the HISTORIAN table does not contain a Typovariavel_id field (exists in the PLC table).
– anonimo