You need to sign in to do that
Don't have an account?
rakesh konda
subquery concept
Hello Guys ,
i am confused with the sub query concept in triggers can any one explain me the sub query concept
for eg:
select id,(select id from opportunities) from Account where id IN: Trigger.New
Thanks & Regards,
konda
i am confused with the sub query concept in triggers can any one explain me the sub query concept
for eg:
select id,(select id from opportunities) from Account where id IN: Trigger.New
Thanks & Regards,
konda
Sub Queries or Inner Queries are used when we need to get all the associated child records from parent record.
So whenever you need to query for Parent-to-Child Relationships, you will need to use sub query.
In the example provided by you :
select id,(select id from opportunities) from Account where id IN: Trigger.New
The following query returns the id for each account in trigger.new and then for each account another collection of opportunities containing id.
So suppose there is an Account on which your trigger is executed and it has 3 opportunities associated with it, so this query will return Id of that Account and 3 ID's of child opportunities associated with that account.
Hope this helps!
Please let me know if you have any doubts, else if this answered your question then mark it as Solved so that others can view it as a proper solution.
Thanks,
Apoorv