Could you please help me with the syntaxis of this SOQL Query? I would like to do an INNER JOIN between A and B on A.FamilyMember=B.ID

SELECT A.FamilyMember__c


WHERE A.StartDate__c > TODAY AND A.EndDate__c < TODAY

AND (SELECT ID FROM B Where Membre__c = True)

  • SOQL does not have a notion of an inner join as such. Instead, we use Relationship Queries. I don't think I follow the final AND clause well enough to make a suggestion, though - can you add more description of your objective and your Salesforce data model?
    – David Reed
    Nov 14, 2018 at 13:16
  • You might find salesforce.stackexchange.com/questions/156278/… to be helpful. In my answer on that question, I go into a fair bit of depth about "joins" in SOQL.
    – Derek F
    Nov 14, 2018 at 13:22

1 Answer 1

select Id, FamilyMember__c
from A
where StartDate__c > TODAY
    and EndDate__c < TODAY
    and FamilyMember__c in (
        select Id
        from B
        where Membre__c = true

this SOQL is split into 2 parts:

  • select Ids of B with condition (Membre__c = True), this is inner select
  • select A with condition (FamilyMember__c is in ids of records from previous step)
  • But by that way, Id field shows the Id values of the A Object. I want to display the Id field of the object B.
    – fromero
    Nov 14, 2018 at 13:22
  • 1
    according to your data model in question, Id of B is stored in FamilyMember__c field on A object. Nov 14, 2018 at 13:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .