 Hello, everyone. I'm Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. StudySoulsalesforce.com is my website or video library to learn Salesforce. In this video, I'm going to demonstrate how you can apply child to parent SOQL on a standard look of field. So this is the scenario that I'm going to implement. So I will be querying context created last week. And if phone is not populated on contact, then I need to copy phone number of related account. So I will be applying query on context and through that query, I will be fetching phone field of related account. So that's why it will be child to parent SOQL. And if I take you to the org and if I go to object manager, open contact object. So in fields and relationship, you can see this look up to account is standard field. So in this video, the child to parent SOQL, we are applying on this standard look of field, right? So you just need to focus on this field name, right? So you need to use this field name, right? So with this API, you can attach particular field using dot. So let's say I need to fetch account phone number. So I will be writing account dot phone, right? So I'm focusing on this standard of field because if you have custom look of field, then in that case, you need to add underscore underscore R as well. So that I will be demonstrating demonstrating in my another video. So in this video, we are just focusing on the child to parent SOQL where look up field is standard. So moving to developer console. So let me show you how we can write SOQL first. So contact ID, first name, phone, then account dot phone. So here you can see I used account then dot phone. So account is the field name, which is available here in this look of field. And this phone is the account of field that I'm fetching. And then from contact where account ID not equals to null. So I'm clicking on execute. So here you can see ID, first name and phone. These are fields fetched from contact and account dot phone. This is the value which is available in the related account. Those are related to particular contact. Now we need to check if on contact a phone is not populated. So here you can see three contacts are there where phone field is not populated. So I will be copying this account phone in these three fields. Right. So I need to implement code in such a way so that existing values won't modify. Only those contacts phone field should be modified where already phone value is not available. So I will be using this SOQL. So I'm copying this. Now here I am creating a list of contact. And here I'm pasting this. And to make it more readable, I'm breaking it into different lines. So now I need to check whether it is empty or not. So I'm using this method. So I used not con list dot empty dot is empty. So if it is true, this complete condition, it means list is not empty. So I can apply conditions accordingly. So I need to apply a loop inside this loop. I need to check this con instance. So if con dot phone not equals to null, sorry, equals to null. If it is null, not having any value. So you can write con dot phone equals to con dot account dot phone. So through this con, you need to go to account and then phone because we already query this here. So this way wherever in contact phone field is blank, in that phone field, related accounts phone will be populated. Let's check why this error is coming. So expecting curly base but was if okay. So I need to implement it in matter. So I just forgot that public static void. Copy account phone to contact. And I'm moving this whole code inside this method. Right now after completion of this, if I again need to check on list. If it is not empty, then update con list. So this way you can apply child to parent s oql wherever your lookup is standard. If you have custom lookup fields, so in that case we need to modify this s oql. So that I will be demonstrating in my another video where I will be having another use case where custom object and custom lookup field will be there. So I'm saving this code. So copying this method name, pasting it here and clicking on execute. Now, I'm going to run that s oql again, so that we can check whether those three records are filled or not with their phone values. Here you can see our field and they are having same value which are available in account form. And rest of the context phone is as is. So this way, with the help of this code, I hope you understood how we can apply child to parent s oql where all the objects are standard and lookup field is also standard. So with this way you are able to understand like how to query data and how we can iterate that so that we can update the information. So thank you for watching this video watch another video so that you can learn how we can apply this s oql child to parent where lookup field is custom. Thank you.