You need to sign in to do that
Don't have an account?
Shruthi GM 4
how to write query inside a query?
I want to get the contacts related to a particular account.So how I write a query for that?
List <Contact> contacts= [Select Name,Id from Contact where (What needs to be written here?)];
Please help.
Thanks inadvance.
List <Contact> contacts= [Select Name,Id from Contact where (What needs to be written here?)];
Please help.
Thanks inadvance.
Id accId = '001b000003KenKW';
List <Contact> contacts = [SELECT Id, Name FROM Contact WHERE AccountId = :accId];
Thanks,
Richard.
If you want to get contacts related to particular account, you can query using Account ID. Here, AccId is the ID of the Account whose contacts can be retrieved.
For Nested Query Example:
To use Nested queries, please find below links.
http://blog.jeffdouglas.com/2010/02/22/soql-how-i-query-with-thee-let-me-count-the-ways/
https://developer.salesforce.com/page/A_Deeper_look_at_SOQL_and_Relationship_Queries_on_Force.com
https://developer.salesforce.com/forums/?id=906F00000009398IAA
I would like to know if that helps you.
Best Regards,
BALAJI
Please check below post for SOQL
1) https://developer.salesforce.com/page/A_Deeper_look_at_SOQL_and_Relationship_Queries_on_Force.com
2) https://developer.salesforce.com/page/From_SQL_to_SOQL
Please try below code.
Option 1:- Option 2:-
Let us know if this will help you