You need to sign in to do that
Don't have an account?

Regarding how to Query records from 4 Standars objects
how we Query records from Account,contacts,opportunity and campaign?
You need to sign in to do that
Don't have an account?
how we Query records from Account,contacts,opportunity and campaign?
There is not relation between all four object but only three objects are having relationship like Account is parent of Contact and Opportunity so SOQL can be
[Select id , (Select id from Opportunities) , (Select id from contacts) from Account ] but Campaign is not related to these in any way but we can set up relation ship creating custom lookup field but that is dependent on requirement.
All Answers
It is very simple using SOQL (Salesfoce Object query Language)
List<Account> ListofAccount = new List<Account>()
Listof Optty = [select id, Name from Account ] ;
List<contact> ListofContacts = new List<contact>()
Listof Optty = [select id, Name from contact ] ;
List<Opportunity> ListofOptty = new List<Opportunity>()
Listof Optty = [select id, Name from Opportunity ] ;
List<Campaign> ListofCampaigns = new List<Campaign>()
Listof Optty = [select id, Name from Campaign ] ;
forgot to mention, is it possible to do in single SOQL statement
There is not relation between all four object but only three objects are having relationship like Account is parent of Contact and Opportunity so SOQL can be
[Select id , (Select id from Opportunities) , (Select id from contacts) from Account ] but Campaign is not related to these in any way but we can set up relation ship creating custom lookup field but that is dependent on requirement.
thank you sandeep