SOQL with conditions on childrenSOQL Error “Didn't understand relationship 'Addresses__r' in field path…”SOQL help with subquery where clauseNot able to query on standard Asset field 'ProductCode' . Please suggestHaving Trouble with Parent-to-Child lookup/SOQL QueryGenrating apex class using Tooling API throws exception while using relationship field in SOQL queryfetching account lookup value on case in inner querySOQL query with inner query doesn't recognize understand the relationshipINVALID_FIELD on SOQL Query through REST APIQuery for parent-to-child (lookup)fetch leads whos id match with Campagain

How quickly could a country build a tall concrete wall around a city?

Plausibility of Ice Eaters in the Arctic

What is the best way to cause swarm intelligence to be destroyed?

How do I explain to a team that the project they will work on for six months will 100% fail?

Is multiplication of real numbers uniquely defined as being distributive over addition?

How to display a duet in lyrics?

Can ads on a page read my password?

Improving software when the author can see no need for improvement

How can I tell if a flight itinerary is fake?

"How do you solve a problem like Maria?"

Why is there a need to prevent a racist, sexist, or otherwise bigoted vendor from discriminating who they sell to?

Team goes to lunch frequently, I do intermittent fasting but still want to socialize

Word or idiom defining something barely functional

How does The Fools Guild make its money?

Why are there so many Doppler Effect formulas?

Best gun to modify into a monsterhunter weapon?

Why was CPU32 core created, and how is it different from 680x0 CPU cores?

Does this Foo machine halt?

How would I as a DM create a smart phone-like spell/device my players could use?

How to query data in backups?

In the movie Harry Potter and the Order or the Phoenix, why didn't Mr. Filch succeed to open the Room of Requirement if it's what he needed?

How can glass marbles naturally occur in a desert?

Is The Lion King live action film made in motion capture?

Why couldn't soldiers sight their own weapons without officers' orders?



SOQL with conditions on children


SOQL Error “Didn't understand relationship 'Addresses__r' in field path…”SOQL help with subquery where clauseNot able to query on standard Asset field 'ProductCode' . Please suggestHaving Trouble with Parent-to-Child lookup/SOQL QueryGenrating apex class using Tooling API throws exception while using relationship field in SOQL queryfetching account lookup value on case in inner querySOQL query with inner query doesn't recognize understand the relationshipINVALID_FIELD on SOQL Query through REST APIQuery for parent-to-child (lookup)fetch leads whos id match with Campagain






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








1















I'm unable to finish an easy query, I could use some help on this.



I got a junction object called Creche_Zone_de_Tarification__c that links two objects (Account and Zone_de_tarification__c and that second is the one I want to query)



There is a Master-Detail relationship between Zone_de_tarification__c and Creche_Zone_de_Tarification__c, as you can see here :



enter image description here



I have a list of Creche_Zone_de_Tarification__c and want fill a list of Zone_de_tarification__c :
I have to retrieve all Zone_de_tarification__c that are linked to a Creche_Zone_de_Tarification__c from the input list.



The relationship between the two objects is called : Creches_de_Zone_de_Tarification__r (cf screenshot juste before)



To describe this part of the project, I insert a list of Creche_Zone_de_Tarification__c, and whant to retrieve whose Zone_de_tarification__c are affected in order to do some treatment.



This works (no condition) :
enter image description here



But when I try to add my where clause, everything goes down :



enter image description here



The error is :
No such column 'Creches_de_Zone_de_Tarification__r' on entity 'Zone_de_Tarification__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.



As I understand the query, I am on a parent object and want the WHERE clause to be on a field on the children,
So it should be :
WHERE Relationship__r.field IN :(parentField) ?










share|improve this question





















  • 1





    it would be better if you can copy paste code instead of screenshot

    – salesforce-sas
    Jul 29 at 14:17











  • I thought that because I used custom objects, it wasn't appropriate, I should have done it anyway ? I'll do next time

    – Alexis MASSON
    Jul 29 at 14:19

















1















I'm unable to finish an easy query, I could use some help on this.



I got a junction object called Creche_Zone_de_Tarification__c that links two objects (Account and Zone_de_tarification__c and that second is the one I want to query)



There is a Master-Detail relationship between Zone_de_tarification__c and Creche_Zone_de_Tarification__c, as you can see here :



enter image description here



I have a list of Creche_Zone_de_Tarification__c and want fill a list of Zone_de_tarification__c :
I have to retrieve all Zone_de_tarification__c that are linked to a Creche_Zone_de_Tarification__c from the input list.



The relationship between the two objects is called : Creches_de_Zone_de_Tarification__r (cf screenshot juste before)



To describe this part of the project, I insert a list of Creche_Zone_de_Tarification__c, and whant to retrieve whose Zone_de_tarification__c are affected in order to do some treatment.



This works (no condition) :
enter image description here



But when I try to add my where clause, everything goes down :



enter image description here



The error is :
No such column 'Creches_de_Zone_de_Tarification__r' on entity 'Zone_de_Tarification__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.



As I understand the query, I am on a parent object and want the WHERE clause to be on a field on the children,
So it should be :
WHERE Relationship__r.field IN :(parentField) ?










share|improve this question





















  • 1





    it would be better if you can copy paste code instead of screenshot

    – salesforce-sas
    Jul 29 at 14:17











  • I thought that because I used custom objects, it wasn't appropriate, I should have done it anyway ? I'll do next time

    – Alexis MASSON
    Jul 29 at 14:19













1












1








1


1






I'm unable to finish an easy query, I could use some help on this.



I got a junction object called Creche_Zone_de_Tarification__c that links two objects (Account and Zone_de_tarification__c and that second is the one I want to query)



There is a Master-Detail relationship between Zone_de_tarification__c and Creche_Zone_de_Tarification__c, as you can see here :



enter image description here



I have a list of Creche_Zone_de_Tarification__c and want fill a list of Zone_de_tarification__c :
I have to retrieve all Zone_de_tarification__c that are linked to a Creche_Zone_de_Tarification__c from the input list.



The relationship between the two objects is called : Creches_de_Zone_de_Tarification__r (cf screenshot juste before)



To describe this part of the project, I insert a list of Creche_Zone_de_Tarification__c, and whant to retrieve whose Zone_de_tarification__c are affected in order to do some treatment.



This works (no condition) :
enter image description here



But when I try to add my where clause, everything goes down :



enter image description here



The error is :
No such column 'Creches_de_Zone_de_Tarification__r' on entity 'Zone_de_Tarification__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.



As I understand the query, I am on a parent object and want the WHERE clause to be on a field on the children,
So it should be :
WHERE Relationship__r.field IN :(parentField) ?










share|improve this question
















I'm unable to finish an easy query, I could use some help on this.



I got a junction object called Creche_Zone_de_Tarification__c that links two objects (Account and Zone_de_tarification__c and that second is the one I want to query)



There is a Master-Detail relationship between Zone_de_tarification__c and Creche_Zone_de_Tarification__c, as you can see here :



enter image description here



I have a list of Creche_Zone_de_Tarification__c and want fill a list of Zone_de_tarification__c :
I have to retrieve all Zone_de_tarification__c that are linked to a Creche_Zone_de_Tarification__c from the input list.



The relationship between the two objects is called : Creches_de_Zone_de_Tarification__r (cf screenshot juste before)



To describe this part of the project, I insert a list of Creche_Zone_de_Tarification__c, and whant to retrieve whose Zone_de_tarification__c are affected in order to do some treatment.



This works (no condition) :
enter image description here



But when I try to add my where clause, everything goes down :



enter image description here



The error is :
No such column 'Creches_de_Zone_de_Tarification__r' on entity 'Zone_de_Tarification__c'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names.



As I understand the query, I am on a parent object and want the WHERE clause to be on a field on the children,
So it should be :
WHERE Relationship__r.field IN :(parentField) ?







soql dynamic-soql childrelationship






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jul 29 at 14:15









Adrian Larson

115k19 gold badges135 silver badges274 bronze badges




115k19 gold badges135 silver badges274 bronze badges










asked Jul 29 at 14:12









Alexis MASSONAlexis MASSON

4372 silver badges13 bronze badges




4372 silver badges13 bronze badges










  • 1





    it would be better if you can copy paste code instead of screenshot

    – salesforce-sas
    Jul 29 at 14:17











  • I thought that because I used custom objects, it wasn't appropriate, I should have done it anyway ? I'll do next time

    – Alexis MASSON
    Jul 29 at 14:19












  • 1





    it would be better if you can copy paste code instead of screenshot

    – salesforce-sas
    Jul 29 at 14:17











  • I thought that because I used custom objects, it wasn't appropriate, I should have done it anyway ? I'll do next time

    – Alexis MASSON
    Jul 29 at 14:19







1




1





it would be better if you can copy paste code instead of screenshot

– salesforce-sas
Jul 29 at 14:17





it would be better if you can copy paste code instead of screenshot

– salesforce-sas
Jul 29 at 14:17













I thought that because I used custom objects, it wasn't appropriate, I should have done it anyway ? I'll do next time

– Alexis MASSON
Jul 29 at 14:19





I thought that because I used custom objects, it wasn't appropriate, I should have done it anyway ? I'll do next time

– Alexis MASSON
Jul 29 at 14:19










1 Answer
1






active

oldest

votes


















3














If you have a list of child ids you want to filter on, your syntax will look as follows:



List<MyObject__c> records = [
SELECT Id FROM MyObject__c WHERE Id IN (
SELECT MyObject__c FROM Child__c WHERE Id IN :childIds
)
];





share|improve this answer



























    Your Answer








    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "459"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f271441%2fsoql-with-conditions-on-children%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    3














    If you have a list of child ids you want to filter on, your syntax will look as follows:



    List<MyObject__c> records = [
    SELECT Id FROM MyObject__c WHERE Id IN (
    SELECT MyObject__c FROM Child__c WHERE Id IN :childIds
    )
    ];





    share|improve this answer





























      3














      If you have a list of child ids you want to filter on, your syntax will look as follows:



      List<MyObject__c> records = [
      SELECT Id FROM MyObject__c WHERE Id IN (
      SELECT MyObject__c FROM Child__c WHERE Id IN :childIds
      )
      ];





      share|improve this answer



























        3












        3








        3







        If you have a list of child ids you want to filter on, your syntax will look as follows:



        List<MyObject__c> records = [
        SELECT Id FROM MyObject__c WHERE Id IN (
        SELECT MyObject__c FROM Child__c WHERE Id IN :childIds
        )
        ];





        share|improve this answer













        If you have a list of child ids you want to filter on, your syntax will look as follows:



        List<MyObject__c> records = [
        SELECT Id FROM MyObject__c WHERE Id IN (
        SELECT MyObject__c FROM Child__c WHERE Id IN :childIds
        )
        ];






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jul 29 at 14:13









        Adrian LarsonAdrian Larson

        115k19 gold badges135 silver badges274 bronze badges




        115k19 gold badges135 silver badges274 bronze badges






























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Salesforce Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f271441%2fsoql-with-conditions-on-children%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Grendel Contents Story Scholarship Depictions Notes References Navigation menu10.1093/notesj/gjn112Berserkeree

            Area configuration aggregation error after install Porto themeMagento 2.1 CE Installed but front/backend not loading/workingCSS not loading on page within Magento 2 pageCannot install module in Magento 2no commands defined in the “setup” namespace. in Magento2Magento 2: Static files are present but shows 404Why do i have to always run the commands to clean cache in Magento 2.1.8?Failure reason: 'Unable to unserialize value.'Error 500 after magento migrationIn production mode the site does not loadMagento 2 : Error 500 after installing

            Middle Expansion Olielle Resaix Definition: Uttering songs of triumph shouting with joy triumphant exulting Sejunction Journal 붙다 달 고급 품목 외출 The stretch trades the screeching tin. Definition: The act of speaking with a drawl a drawl Cough Sand Definition: An uproar a quarrel a noisy outbreak Shake Iron Publicize Horse House Baby 사과 Resaix Flaggy Jelly Temporary Unequaled Puppet A drop in the bucket Shrew 성격 회원 성질 미팅 The burn frames the tacky quality. Materialistic The smoke reduces the way. Yammoe Nondescript Cheek 얼굴 배 약하다 날리다 타다 The illegal country shows the iron. Help Rule Drearien Smoke Teaching Meaty Wasp Abraham Lincoln Jaws 진심 수리하다 Size Cork Idea Convert Think Lark John Lennon 거울 청소 군 추천하다 아이스크림