Mina Garas Daniel
Registered User.
- Local time
- Today, 04:27
- Joined
- Jul 21, 2017
- Messages
- 66
I understand the concept of layered queries. I've used six-layer queries myself once or twice. They worked fine for me. Normally, though, you don't consume resources like that when opening a query unless there is something odd about the query. Which is why I asked if you could post the SQL of the seven or eight queries.
There are SQL sentences for layered quries
Qry1
SELECT QOD_OrdLog.ODID, QOD_OrdLog.ODPK, QOD_OrdLog.PDate, QOD_OrdLog.Kitchen, QOD_OrdLog.Job_Order, QOD_OrdLog.TDPK, QOD_OrdLog.ERP_Code AS FP_ERP_Code, QOD_OrdLog.Item_Eng AS FP_Eng_Name, QOD_OrdLog.Item_Arb AS FP_Arb_Name, QFP_RecPHIP.Unit_Arb, QOD_OrdLog.OQty, QFP_RecPHIP.RPFPType, QFP_RecPHIP.PHIPPK, QFP_RecPHIP.RawCode, QFP_RecPHIP.ERP_Code, QFP_RecPHIP.QFP_RecipeDtl.QRP_RPFP.Item_Eng, QFP_RecPHIP.Brand, QFP_RecPHIP.Item_Arb, QFP_RecPHIP.Unit, QFP_RecPHIP.PQty, [PQty]*[OQty] AS Batch
FROM QOD_OrdLog INNER JOIN QFP_RecPHIP ON QOD_OrdLog.TDPK = QFP_RecPHIP.TDPK;
Qry2
SELECT QOD_FP.ODID, QOD_FP.ODPK, QOD_FP.PDate, QOD_FP.Kitchen, QOD_FP.Job_Order, QOD_FP.TDPK, QOD_FP.PHIPPK, QOD_FP.ERP_Code, QOD_FP.RawCode, QOD_FP.Item_Eng, QOD_FP.Item_Arb, QFP_RecPHIP.PHIP_Unit, QFP_RecPHIP.Unit_Arb, QFP_RecPHIP.RecipePK, QFP_RecPHIP.PHIPPK AS PHIPPK1, QFP_RecPHIP.RPFPType AS PHIP1_Type, QFP_RecPHIP.RawCode AS RawCode1, QFP_RecPHIP.ERP_Code AS ERP_Code1, QFP_RecPHIP.QFP_RecipeDtl.QRP_RPFP.Item_Eng AS RPFP_Eng1, QFP_RecPHIP.Brand, QFP_RecPHIP.Item_Arb AS RPFP_Arb1, QFP_RecPHIP.Unit AS PHIP1_Unit, QOD_FP.OQty, QFP_RecPHIP.PQty AS PHIP1_Qty, [OQty]*[PHIP1_Qty] AS PHIP1_Batch
FROM QOD_FP LEFT JOIN QFP_RecPHIP ON QOD_FP.PHIPPK = QFP_RecPHIP.TDPK;
Qry3
SELECT QOD_PHIP1Filling.ODID, QOD_PHIP1Filling.ODPK, QOD_PHIP1Filling.PDate, QOD_PHIP1Filling.Kitchen, QOD_PHIP1Filling.Job_Order, QOD_PHIP1Filling.TDPK, QOD_PHIP1Filling.PHIPPK1, QOD_PHIP1Filling.ERP_Code1, QOD_PHIP1Filling.RawCode1, QOD_PHIP1Filling.PHIP1_Type, QOD_PHIP1Filling.RPFP_Eng1, QOD_PHIP1Filling.RPFP_Arb1, QOD_PHIP1Filling.PHIP1_Unit, QFP_RecPHIP.Unit_Arb, QFP_RecPHIP.RecipePK, QFP_RecPHIP.PHIPPK AS PHIPPK2, QFP_RecPHIP.RPFPType AS PHIP2_Type, QFP_RecPHIP.RawCode AS RawCode2, QFP_RecPHIP.ERP_Code AS ERP_Code2, QFP_RecPHIP.QFP_RecipeDtl.QRP_RPFP.Item_Eng AS RPFP_Eng2, QFP_RecPHIP.Brand, QFP_RecPHIP.Item_Arb AS RPFP_Arb2, QFP_RecPHIP.Unit AS PHIP_Unit2, QOD_PHIP1Filling.PHIP1_Batch, QFP_RecPHIP.PQty AS PHIP2_Qty, [PHIP1_Batch]*[PQty] AS PHIP2_Batch
FROM QOD_PHIP1Filling LEFT JOIN QFP_RecPHIP ON QOD_PHIP1Filling.PHIPPK1 = QFP_RecPHIP.TDPK
WHERE (((QOD_PHIP1Filling.PHIP1_Unit)="Pcs"));
Qry4
SELECT QOD_SumPHIP2.ODID, QOD_SumPHIP2.ODPK, QOD_SumPHIP2.PDate, QOD_SumPHIP2.Kitchen, QOD_SumPHIP2.Job_Order, QOD_SumPHIP2.TDPK, QOD_SumPHIP2.PHIPPK1, QOD_SumPHIP2.RawCode1, QOD_SumPHIP2.ERP_Code1, QOD_SumPHIP2.PHIP1_Type, QOD_SumPHIP2.RPFP_Eng1, QOD_SumPHIP2.RPFP_Arb1, QFP_RecPHIP.PHIP_Unit AS PHIP1_Unit, QFP_RecPHIP.Unit_Arb, QFP_RecPHIP.PHIPPK AS PHIPPK3, QFP_RecPHIP.RecipePK, QFP_RecPHIP.RawCode AS RawCode3, QFP_RecPHIP.ERP_Code AS ERP_Code3, QFP_RecPHIP.RPFPType AS PHIP3_Type, QFP_RecPHIP.QFP_RecipeDtl.QRP_RPFP.Item_Eng AS RPFP_Eng3, QFP_RecPHIP.Brand, QFP_RecPHIP.Item_Arb AS RPFP_Arb3, QFP_RecPHIP.Unit AS PHIP3_Unit, QOD_SumPHIP2.PHIP1_Batch, ([PHIP1_Batch]/[QFP_RecPHIP]![PHIP_LR])*[QFP_RecPHIP]![IngPer] AS PHIP3_Batch
FROM QOD_SumPHIP2 LEFT JOIN QFP_RecPHIP ON QOD_SumPHIP2.PHIPPK1 = QFP_RecPHIP.TDPK
WHERE (((QOD_SumPHIP2.PHIP1_Type) Like "IP" Or (QOD_SumPHIP2.PHIP1_Type)="PH"));
Qry5
SELECT QOD_PHIP3.ODID, QOD_PHIP3.ODPK, QOD_PHIP3.PDate, QOD_PHIP3.Kitchen, QOD_PHIP3.Job_Order, QOD_PHIP3.TDPK, QOD_PHIP3.PHIPPK3, QOD_PHIP3.RawCode3, QOD_PHIP3.ERP_Code3, QOD_PHIP3.PHIP3_Type, QOD_PHIP3.RPFP_Eng3, QOD_PHIP3.RPFP_Arb3, QFP_RecPHIP.PHIP_Unit AS PHIP3_Unit, QFP_RecPHIP.Unit_Arb, QFP_RecPHIP.PHIPPK AS PHIPPK4, QFP_RecPHIP.RecipePK, QFP_RecPHIP.RawCode AS RawCode4, QFP_RecPHIP.ERP_Code AS ERP_Code4, QFP_RecPHIP.RPFPType AS PHIP4_Type, QFP_RecPHIP.QFP_RecipeDtl.QRP_RPFP.Item_Eng AS RPFP_Eng4, QFP_RecPHIP.Brand, QFP_RecPHIP.Item_Arb AS RPFP_Arb4, QFP_RecPHIP.Unit AS PHIP_Unit4, QOD_PHIP3.PHIP3_Batch, ([PHIP3_Batch]/[QFP_RecPHIP]![PHIP_LR])*[QFP_RecPHIP]![IngPer] AS PHIP4_Batch
FROM QOD_PHIP3 LEFT JOIN QFP_RecPHIP ON QOD_PHIP3.PHIPPK3 = QFP_RecPHIP.TDPK
WHERE (((QOD_PHIP3.PHIP3_Type) Like "IP" Or (QOD_PHIP3.PHIP3_Type)="PH"));
Qry6
SELECT QOD_PHIP4.ODID, QOD_PHIP4.ODPK, QOD_PHIP4.PDate, QOD_PHIP4.Kitchen, QOD_PHIP4.Job_Order, QOD_PHIP4.TDPK, QOD_PHIP4.PHIPPK4, QOD_PHIP4.RawCode4, QOD_PHIP4.ERP_Code4, QOD_PHIP4.PHIP4_Type, QOD_PHIP4.RPFP_Eng4, QOD_PHIP4.RPFP_Arb4, QFP_RecPHIP.PHIP_Unit AS PHIP4_Unit, QFP_RecPHIP.Unit_Arb, QFP_RecPHIP.PHIPPK AS PHIPPK5, QFP_RecPHIP.RecipePK, QFP_RecPHIP.RawCode AS RawCode5, QFP_RecPHIP.ERP_Code AS ERP_Code5, QFP_RecPHIP.RPFPType AS PHIP5_Type, QFP_RecPHIP.QFP_RecipeDtl.QRP_RPFP.Item_Eng AS RPFP_Eng5, QFP_RecPHIP.Brand, QFP_RecPHIP.Item_Arb AS RPFP_Arb5, QFP_RecPHIP.Unit AS PHIP5_Unit, QOD_PHIP4.PHIP4_Batch, ([PHIP4_Batch]/[QFP_RecPHIP]![PHIP_LR])*[QFP_RecPHIP]![IngPer] AS PHIP5_Batch
FROM QOD_PHIP4 LEFT JOIN QFP_RecPHIP ON QOD_PHIP4.PHIPPK4 = QFP_RecPHIP.TDPK
WHERE (((QOD_PHIP4.PHIP4_Type) Like "IP" Or (QOD_PHIP4.PHIP4_Type)="PH"));
Qry7 (Union query)
SELECT QOD_SumPHIP2.ODID, QOD_SumPHIP2.ODPK, QOD_SumPHIP2.PDate, QOD_SumPHIP2.Kitchen, QOD_SumPHIP2.Job_Order, QOD_SumPHIP2.TDPK, QOD_SumPHIP2.PHIPPK1, QOD_SumPHIP2.RawCode1, QOD_SumPHIP2.ERP_Code1, QOD_SumPHIP2.PHIP1_Type, QOD_SumPHIP2.RPFP_Eng1, QOD_SumPHIP2.RPFP_Arb1, QFP_RecPHIP.PHIP_Unit AS PHIP1_Unit, QFP_RecPHIP.Unit_Arb, QFP_RecPHIP.PHIPPK AS PHIPPK3, QFP_RecPHIP.RecipePK, QFP_RecPHIP.RawCode AS RawCode3, QFP_RecPHIP.ERP_Code AS ERP_Code3, QFP_RecPHIP.RPFPType AS PHIP3_Type, QFP_RecPHIP.QFP_RecipeDtl.QRP_RPFP.Item_Eng AS RPFP_Eng3, QFP_RecPHIP.Brand, QFP_RecPHIP.Item_Arb AS RPFP_Arb3, QFP_RecPHIP.Unit AS PHIP3_Unit, QOD_SumPHIP2.PHIP1_Batch, ([PHIP1_Batch]/[QFP_RecPHIP]![PHIP_LR])*[QFP_RecPHIP]![IngPer] AS PHIP3_Batch
FROM QOD_SumPHIP2 LEFT JOIN QFP_RecPHIP ON QOD_SumPHIP2.PHIPPK1 = QFP_RecPHIP.TDPK
WHERE (((QOD_SumPHIP2.PHIP1_Type) Not Like "Raw"));
UNION SELECT QOD_PHIP3.ODID, QOD_PHIP3.ODPK, QOD_PHIP3.PDate, QOD_PHIP3.Kitchen, QOD_PHIP3.Job_Order, QOD_PHIP3.TDPK, QOD_PHIP3.PHIPPK3, QOD_PHIP3.RawCode3, QOD_PHIP3.ERP_Code3, QOD_PHIP3.PHIP3_Type, QOD_PHIP3.RPFP_Eng3, QOD_PHIP3.RPFP_Arb3, QFP_RecPHIP.PHIP_Unit AS PHIP3_Unit, QFP_RecPHIP.Unit_Arb, QFP_RecPHIP.PHIPPK AS PHIPPK4, QFP_RecPHIP.RecipePK, QFP_RecPHIP.RawCode AS RawCode4, QFP_RecPHIP.ERP_Code AS ERP_Code4, QFP_RecPHIP.RPFPType AS PHIP4_Type, QFP_RecPHIP.QFP_RecipeDtl.QRP_RPFP.Item_Eng AS RPFP_Eng4, QFP_RecPHIP.Brand, QFP_RecPHIP.Item_Arb AS RPFP_Arb4, QFP_RecPHIP.Unit AS PHIP_Unit4, QOD_PHIP3.PHIP3_Batch, ([PHIP3_Batch]/[QFP_RecPHIP]![PHIP_LR])*[QFP_RecPHIP]![IngPer] AS PHIP4_Batch
FROM QOD_PHIP3 LEFT JOIN QFP_RecPHIP ON QOD_PHIP3.PHIPPK3 = QFP_RecPHIP.TDPK
WHERE (((QOD_PHIP3.PHIP3_Type) Like "IP" Or (QOD_PHIP3.PHIP3_Type)="PH"));
UNION SELECT QOD_PHIP4.ODID, QOD_PHIP4.ODPK, QOD_PHIP4.PDate, QOD_PHIP4.Kitchen, QOD_PHIP4.Job_Order, QOD_PHIP4.TDPK, QOD_PHIP4.PHIPPK4, QOD_PHIP4.RawCode4, QOD_PHIP4.ERP_Code4, QOD_PHIP4.PHIP4_Type, QOD_PHIP4.RPFP_Eng4, QOD_PHIP4.RPFP_Arb4, QFP_RecPHIP.PHIP_Unit AS PHIP4_Unit, QFP_RecPHIP.Unit_Arb, QFP_RecPHIP.PHIPPK AS PHIPPK5, QFP_RecPHIP.RecipePK, QFP_RecPHIP.RawCode AS RawCode5, QFP_RecPHIP.ERP_Code AS ERP_Code5, QFP_RecPHIP.RPFPType AS PHIP5_Type, QFP_RecPHIP.QFP_RecipeDtl.QRP_RPFP.Item_Eng AS RPFP_Eng5, QFP_RecPHIP.Brand, QFP_RecPHIP.Item_Arb AS RPFP_Arb5, QFP_RecPHIP.Unit AS PHIP5_Unit, QOD_PHIP4.PHIP4_Batch, ([PHIP4_Batch]/[QFP_RecPHIP]![PHIP_LR])*[QFP_RecPHIP]![IngPer] AS PHIP5_Batch
FROM QOD_PHIP4 LEFT JOIN QFP_RecPHIP ON QOD_PHIP4.PHIPPK4 = QFP_RecPHIP.TDPK
WHERE (((QOD_PHIP4.PHIP4_Type) Like "IP" Or (QOD_PHIP4.PHIP4_Type)="PH"));
Qry8 (Union query) when i use this one message of Error 3048 appear
SELECT QOD_FP.ODID, QOD_FP.ODPK, QOD_FP.PDate, QOD_FP.Kitchen, QOD_FP.Job_Order, QOD_FP.TDPK, QFP_RecPHIP.PHIPPK AS PHIPPK1, QFP_RecPHIP.RPFPType AS PHIP1_Type, QFP_RecPHIP.RawCode AS RawCode1, QFP_RecPHIP.ERP_Code AS ERP_Code1, QFP_RecPHIP.QFP_RecipeDtl.QRP_RPFP.Item_Eng AS RPFP_Eng1, QFP_RecPHIP.Brand, QFP_RecPHIP.Item_Arb AS RPFP_Arb1, QFP_RecPHIP.Unit AS PHIP1_Unit, [QFP_RecPHIP]![PQty]*[QOD_FP]![OQty] AS PHIP1_Batch
FROM QOD_FP LEFT JOIN QFP_RecPHIP ON QOD_FP.PHIPPK = QFP_RecPHIP.TDPK
WHERE (((QFP_RecPHIP.RPFPType) Not Like "Raw") AND ((QFP_RecPHIP.Unit) Not Like "Pcs"));
UNION SELECT QOD_PHIP1Filling.ODID, QOD_PHIP1Filling.ODPK, QOD_PHIP1Filling.PDate, QOD_PHIP1Filling.Kitchen, QOD_PHIP1Filling.Job_Order, QOD_PHIP1Filling.TDPK, QFP_RecPHIP.PHIPPK AS PHIPPK2, QFP_RecPHIP.RPFPType AS PHIP2_Type, QFP_RecPHIP.RawCode AS RawCode2, QFP_RecPHIP.ERP_Code AS ERP_Code2, QFP_RecPHIP.QFP_RecipeDtl.QRP_RPFP.Item_Eng AS RPFP_Eng2, QFP_RecPHIP.Brand, QFP_RecPHIP.Item_Arb AS RPFP_Arb2, QFP_RecPHIP.Unit AS PHIP_Unit2, [QOD_PHIP1Filling]![PHIP1_Batch]*[QFP_RecPHIP]![PQty] AS PHIP2_Batch
FROM QOD_PHIP1Filling LEFT JOIN QFP_RecPHIP ON QOD_PHIP1Filling.PHIPPK1 = QFP_RecPHIP.TDPK
WHERE (((QOD_PHIP1Filling.PHIP1_Unit)="Pcs"));
Thanks