Question :
I Have 4 tables:
Documents
, document_tag
, doc_document_tag
and log
.
- In
document
:doc_id
,Doc_name
are saved - In
Doc_tag
:Tag_id
,Tag_name
are saved -
In
doc_document_tag
multiple tags are save against one or more
documents.for every table logs are generated.
My question is that in my case in doc_document_tag
only tag_id
is saved and I need tag_name
Answer :
Based on your description, the Doc_Tag
table should have the Tag_name
you need.
In the future, giving actual table definitions, some sample data and the actual expected result will help in getting a more accurate and complete answer.
This query example might get you started
SELECT DT.tag_name
FROM dbo.logs L
INNER JOIN dbo.doc_document_tag DDT
ON DDT.Tag_id = L.Tag_id
INNER JOIN dbo.Doc_Tag DT
ON DDT.Tag_Id = DT.tag_id;