对于 Accounts 表中的每条记录,我有两个表,例如 Account 和 Grouptxt 我需要在 Grouptxt 表中找到依赖关系,下面是这两个表的示例数据
帐户表数据:-
AccountName,ShortName,Type,OpBal,ParentGroup,Move4Report,DebitLimit,CreditLimit
'C' Mannto,'C' Mannto,客户/供应商,0.0,Debtors Belgaum,True,0.0,0.0
2M Engineers,2M Engineers,客户/供应商,260.0,Debtors Belgaum,True,0.0,0.0
AA Engineering,AA Engineering,Customer/Supplier,114.0,Debtors Belgaum,False,0.0,0.0
AC Enterprises,AC Enterprises,Customer/Supplier,0.0,Creditors for Materials,True,0.0,0.0
Grouptxt 表数据:-
GroupName,ShortName,ParentGroup,isSystem,IsTradingGroup
资产,资产,,真,假
资金申请,资金申请,资产,虚假,虚假
固定资产,固定资产,资金运用,假,假
总块,总块,固定资产,假,假
所以现在我的问题是针对 Account 表中的每条记录,我需要从 grouptxt 表中获取依赖项。如何做到这一点?
O/P 应采用这种格式 Expenditure <-- Materials Consumed <--Raw Material & Components AC Enterprises,AC Enterprises,Customer/Supplier,0.0,Creditors for Materials,True,0.0,0.0
对于记录 ACEnterprises,依赖项是原材料和组件 --> 消耗的材料 --> 支出
像这样我需要为整个表格获取,但不知道如何为整个表格执行此操作
我试过这样
SELECT #AccountName ,a.ShortName ,a.Type ,a.OpBal ,a.ParentGroup ,a.Move4Report ,a.DebitLimit ,a.CreditLimit ,a.row_id, g.ParentGroup AS GrpTxt_ParentGroup FROM Grouptxt g 内部加入帐户 a ON a .ParentGroup=g.ShortName WHERE #AccountName='成品增加/减少'
SELECT * FROM Grouptxt where ParentGroup='Raw Material & Components'
SELECT * FROM Grouptxt 其中 ShortName='Raw Material & Components'
SELECT * FROM Grouptxt where ShortName='Materials Consumed'
SELECT * FROM Grouptxt 其中 ShortName='Expenditure'
提前致谢