Reputation: 327
VISITSEXIT VISITSENTRY VISITOR
idvisitsexit idvisitsentry idvisitor
idvisitsentry idvisitante visitor
idvisitor visitor
visitor
dateexit
timeexit
I need to select the table VISITSEXIT where when she bring the VISITSENTRY also will bring idvisitor and description of idvisitor (visitor).
Upvotes: 1
Views: 1102
Reputation: 79969
A simple straightforward JOIN
will give you what you want:
SELECT
t.idvisitor,
t.visitor,
t.dateexit,
t.timeext,
... -- the rest of the columns you want to select
FROM VISITSEXIT AS t
INNER JOIN VisitEntry AS e ON t.idvisitentry = e.visitentry
INNER JOIN Visitor AS v ON e.idvisitante = v.idvisitor;
You might also need to use LEFT JOIN
if you want to include those unmatched rows from the other tables. See this post for more information about the JOIN
types:
Upvotes: 2