我有两个表,发票和成员,通过字段 InvoiceNum 通过 PK/FK 关系连接。我创建了以下 sql,它工作正常,并按预期提取 44 条记录。
SELECT
INVOICES.InvoiceNum,
INVOICES.GroupNum,
INVOICES.DivisionNum,
INVOICES.DateBillFrom,
INVOICES.DateBillTo
FROM INVOICES
INNER JOIN MEMBERS ON INVOICES.InvoiceNum = MEMBERS.InvoiceNum
WHERE MEMBERS.MemberNum = '20032526000'
现在,我想用INVOICES.GroupNum
and替换INVOICES.DivisionNum
上述查询中的GroupName
and DivisionName
。这些值存在于 Groups 和 Divisions 表中,这些表也具有相应的 Group_num 和 Division_num 字段。我创建了以下 sql。问题是它现在提取了 528 条记录而不是 44 条!
SELECT
INVOICES.InvoiceNum,
INVOICES.DateBillFrom,
INVOICES.DateBillTo,
DIVISIONS.DIVISION_NAME,
GROUPS.GROUP_NAME
FROM INVOICES
INNER JOIN MEMBERS ON INVOICES.InvoiceNum = MEMBERS.InvoiceNum
INNER JOIN GROUPS ON INVOICES.GroupNum = GROUPS.Group_Num
INNER JOIN DIVISIONS ON INVOICES.DivisionNum = DIVISIONS.Division_Num
WHERE MEMBERS.MemberNum = '20032526000'
任何帮助是极大的赞赏。