MySQL 表18_8_ChartOfAccounts
AccountNumber | VatReturnRowNumberForDebitTurnover
-------------------------------------------
1 | 61
2 | 55
MySQL 表2_1_journal
DebitAccount | TransactionPartnerName | Amount
-----------------------------------------------
1 | Name1 | 55
2 | Name2 | 60
MySQL 表18_6_TransactionPartners
CompanyName
-------------------------------
Name1
Name2
Name1
询问
SELECT
AccountNumber,
DebitAccount, TransactionPartnerName, Amount,
CompanyName
FROM 18_8_ChartOfAccounts
LEFT JOIN 2_1_journal
ON AccountNumber = DebitAccount
LEFT JOIN 18_6_TransactionPartners
ON TransactionPartnerName = CompanyName
WHERE VatReturnRowNumberForDebitTurnover = '61' AND Amount = 55
在输出中得到这样的东西
TransactionPartnerName | Amount
-----------------------------------------
Name1 | 55
但是,如表中所示18_6_TransactionPartners
,有两个Name1
名称
TransactionPartnerName | Amount
-----------------------------------------------
Name1 | 55
Name1 | 55
而不是SELECT
尝试SELECT DISTINCT
(相同的结果)。
而不是ON TransactionPartnerName = CompanyName
尝试过ON TransactionPartnerName = CompanyName LIMIT 1
(获取语法错误)。
可能在GROUP BY CompanyName
某个地方需要。
请指教...