You need to sign in to do that
Don't have an account?
Deanna Aaron 4
How to perform a union on a SOQL query
I'm looking to perform a union non a SOQL query. How would I do this?
I'm basically trying to join/combine two queries.
My sample queries are:
SELECT Name, fferpcore__BillingDocument__c, fferpcore__ProductService__c, ffbc__ContractLineItem__c, Id
FROM fferpcore__BillingDocumentLineItem__c
WHERE Include_in_Rev_Rec__c =FALSE
SELECT fferpcore__Account__c, fferpcore__CustomerReference__c, fferpcore__DocumentDate__c, fferpcore__DocumentStatus__c, Total_Invoice__c, ffaci__CongaEmailStatus__c, Id FROM fferpcore__BillingDocument__c WHERE fferpcore__DocumentStatus__c = 'Complete' AND TPx_Special_Invoice__c=FALSE AND fferpcore__DocumentType__c ='Invoice' AND ffaci__CongaEmailStatus__c != 'Sent'
I'm basically trying to join/combine two queries.
My sample queries are:
SELECT Name, fferpcore__BillingDocument__c, fferpcore__ProductService__c, ffbc__ContractLineItem__c, Id
FROM fferpcore__BillingDocumentLineItem__c
WHERE Include_in_Rev_Rec__c =FALSE
SELECT fferpcore__Account__c, fferpcore__CustomerReference__c, fferpcore__DocumentDate__c, fferpcore__DocumentStatus__c, Total_Invoice__c, ffaci__CongaEmailStatus__c, Id FROM fferpcore__BillingDocument__c WHERE fferpcore__DocumentStatus__c = 'Complete' AND TPx_Special_Invoice__c=FALSE AND fferpcore__DocumentType__c ='Invoice' AND ffaci__CongaEmailStatus__c != 'Sent'
Do you have any relationship between fferpcore__BillingDocumentLineItem__c & fferpcore__BillingDocument__c objects?
Regards,
Ankaiah Bandi
As per my understanding fferpcore__BillingDocumentLineItem__c object have a lookup with fferpcore__BillingDocument__c object ,
so here fferpcore__BillingDocument__c is parent and fferpcore__BillingDocumentLineItem__c is child.
So if you want to fetch all childs from it's parent then use below query:-
if you want to fetch related patrent information query:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Thank you, Mukesh. Yes, in this scenario the objects have a parent-child relationship. In regards to Ankaiah's reply, we will have objects that do not have a parent child relationship.
For example:
Contract line item with no shipping address
Payment with an error message in the description field
In this example, there is a relationship between the Contract Line Item and Payment (Not Parent-Child)
The path would be:
Payment > Billing Document > Contract > Contract Line Item
asp04__Payment__c > ffasp__BillingDocument__c > ffbc__Contract__c > ffbc__ContractLineItem__c
How would I create a join the queueries?
SELECT Name, fferpcore__BillingDocument__c, fferpcore__ProductService__c, ffbc__ContractLineItem__c, Id
FROM asp04__Payment__c
WHERE Include_in_Rev_Rec__c =FALSE
---Next---
SELECT fferpcore__Account__c, fferpcore__CustomerReference__c, fferpcore__DocumentDate__c
FROM ffbc__ContractLineItem__c
WHERE fferpcore__DocumentStatus__c = 'Complete' AND TPx_Special_Invoice__c=FALSE AND fferpcore__DocumentType__c ='Invoice'