如何在访问中执行内部联接

时间:2013-12-02 04:27:33

标签: mysql sql ms-access

在Access中我有一个这样的表:

data(BillNo number,acno number)
agro(BillNo number,Price number,qty number)
account(acno,Name)

我想输出如下:

account.acno,account.Name,sum(agro.Price*agro.qty)

我的查询是:

SELECT account.accountnumber, 
       account.name, 
       Sum(agro.price * agro.qty) 
FROM   account 
INNER JOIN (agro 
            INNER JOIN data 
            ON agro.billno = data.billno) 
ON account.accountnumber = data.acno; 

但它不起作用。请帮帮我。

1 个答案:

答案 0 :(得分:2)

您混淆了查询中的文字。应该是这样的:

SELECT account.acno, account.Name,Sum(agro.Price*agro.qty)
FROM account 
INNER JOIN data ON account.acno= data.acno;
INNER JOIN agro On data .BillNo = agro.BillNo 
GROUP BY account.acno, account.name