1
VISITSEXIT              VISITSENTRY               VISITOR
idvisitsexit            idvisitsentry             idvisitor 
idvisitsentry           idvisitante               visitor 
idvisitor               visitor
visitor
dateexit
timeexit

我需要选择表格VISITSEXIT,当她带上VISITSENTRY 时也会带上idvisitor 和idvisitor(访问者)的描述。

4

1 回答 1

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类型的更多信息,请参阅此帖子:

于 2013-03-21T13:26:57.603 回答