 Hello everyone. I'm Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. StudySalesForce.com is my website for video library to learn salesforce. In this video, I'm going to demonstrate a scenario. It will be based on child to parent SOQL where you have created a custom hookup relationship. So loose case is we need to query employees created this week. So employee is custom object under which whatever parts we have to query. And if phone is not populated on employee code, then we need to copy phone of related account. So it means on employee, there must be a lookup relationship to account. So let's jump to employee object. And here you can see, I already have a lookup to account. Right. I have phone. I don't have phone field. So I'm taking that so that we can populate that. So from here, I'm picking phone. Clicking on next. I'm labeling it as phone. It should be available for all the profiles. It should be visible to layout, clicking on save. So phone field is created and on account as we all come to the standard object and phone is the standard field that is available on account. Now let's learn how we can create child to parent SOQL first, then we will be using that SOQL in the ethics board. So select ID, phone underscore underscore C from employer underscore underscore C. This is basic SOQL, which will query all employee reports along with their ID and phone. Now here after comma, I'm putting account. So let's jump to that field. So here field name, this you need to copy, right. And this you need to use here with underscore underscore R then dot phone. So remember that if that relationship that you created is standard. If it is already created by same source, then you just need to use account or whatever field name is there. But in case of custom lookup relationship relationship, we need to add this underscore underscore R dot as well. So here you can see employee IDs are available on employee phone is blank because right now created this field and account phone is available here. Right. If I remove this so it will show an error. Here you can see right and it is giving you suggestion like if it is custom relationship, then we need to append underscore underscore R. So this you need to take care. Right. And if this phone field is standard, so you need to use it as is if it is custom then you need to append underscore underscore C as well. So this way you can try to pick SOQL. Now, I'm copying this so that we can learn how we can use it and apex. Right now you can see three records are available and their phone fields are blank. So I will be writing a quote through which this account phone will be populated in the employee phone fields. So here, static void. Now here, let's stop employee employee is a custom object. That's why I'm using underscore underscore C as a hand then EMP list equals to take this SOQL. Then I'm checking it for now. EMP list is empty. If it is not known, then I'm iterating a loop. So again, employee underscore underscore C this is object API then EMP EMP list. So I'm iterating on employee list. Now, here I need to apply if condition because I first need to check whether phone field that is available on employee it is blank or not. If it is blank, then only I need to populate account phone. So you can be dot phone underscore underscore C double equals to null. And now I can write EMP dot phone underscore underscore C equals to EMP dot account underscore underscore R dot phone. So this way, the accounts phone will be populated on the employer. Right, so this way you can implement your code and after completion of this if block, you can again check EMP list for null and that can write update EMP list. Right, so this way I implemented child to parent SOQL where lookup relationship is custom. So remember you need to use it like this account underscore underscore R. So this we also underscore underscore R by applying parent to child SOQL that I demonstrated in my another video. Right, so I created separate videos for all. So now, first, let me execute this. So I'm saving this pasting it here, clicking on execute, running this SOQL again. And here you can see employee reports are having phone number as their related accounts phone. Right, so this way, I created total four videos. These two are related to parent to child SOQL input the scenarios if relationship field is standard and if relationship field is custom. And two videos for child to parent SOQL, we are again standard relationship and custom relationship. So do watch all four videos they are available in the details so that you can understand the differences. So I hope you understood the scenario very well. This is my website study Salesforce.com so we can fight all the new cases related to Salesforce. Thank you for watching this video.