我有两个表table1和table2 . 两个表都有多列 .
table1: serialno , recordno.... table2: recodno,issueid....
我想从 table1 , issueid 从 table2 中检索 table1.recordno=table2.recordno 条件下的所有行
table1
issueid
table2
table1.recordno=table2.recordno
recordno 来自 table1 是主键 . 我正在使用MS-Access数据库 .
recordno
您可以使用以下任何一种联接:
JOIN:当两个表中至少有一个匹配时返回行,
LEFT JOIN:返回左表中的所有行,即使右表中没有匹配项,
RIGHT JOIN:返回右表中的所有行,即使左表中没有匹配项,
FULL JOIN:当其中一个表中存在匹配时返回行
在你的情况下:
SELECT table1.serialno,table1.recordno, table2.issueid FROM table1 INNER JOIN table2 ON table1.recordno=table2.recordno ORDER BY table1.serialno
SELECT table1.serialno,table1.recordno,table2.issueid FROM table1 LEFT OUTER JOIN table2 ON table1.recordno=table2.recordno
2 回答
您可以使用以下任何一种联接:
JOIN:当两个表中至少有一个匹配时返回行,
LEFT JOIN:返回左表中的所有行,即使右表中没有匹配项,
RIGHT JOIN:返回右表中的所有行,即使左表中没有匹配项,
FULL JOIN:当其中一个表中存在匹配时返回行
在你的情况下: