VISITSEXIT VISITSENTRY VISITOR
idvisitsexit idvisitsentry idvisitor
idvisitsentry idvisitante visitor
idvisitor visitor
visitor
dateexit
timeexit
我需要选择表VISITSEXIT,当她带来VISITSENTRY时,也会带来idvisitor和访问者(访客)的描述。
答案 0 :(得分:2)
一个简单直截了当的JOIN
会给你你想要的东西:
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;
如果要包含其他表中不匹配的行,则可能还需要使用LEFT JOIN
。有关JOIN
类型的详细信息,请参阅此帖子: