function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Software EngineSoftware Engine 

How to combine a single query

 
 
HI  Simon,
 
How to write  a single query from  below three queries.
 
select a.Name,(select FirstName from contact),(Select CloseDate from Opportunity) from Account a
select RepID from user
select CampaignCode from Campaign.
 
 
Table Name          Field
----------------          -----------
Account                 Name
Contact                  FirstName
Campaign              CampaignCode
Opportunity            CloseDate
User                         RepID
 
 
Please help me.
 
 
 
 
 
 
 
 
 
 
 
 
SuperfellSuperfell
You need to detail how all these rows are related to each other before you can write the SOQL.
Software EngineSoftware Engine

Hi,

Thanks for yr response.

I am new to the salesforce. I saw the data model diagram in help document of AppExchange. I could not found any relation with user table to other tables.

Is the ID field common in all the tables?  My task is i have to write a single query from five tables.

I know Opportunity and Contact tables are child tables to Account. But dont know what is relation with user, campaign table to Account table. How to know? Is there any tool like for come to know what is the parent table of a particular table.

Thank you.

 

 

SuperfellSuperfell
Yes, there's an Id on every table.

Your task as you've currently stated it makes no sense, there are multiple relationships to user from every single table, which exact data set are you trying to access by your query ?

There's an entity relationship diagram in the API docs for all the standard tables, that should show how campaigns fit into the data model. Tools like SoqlXplorer ApexExplorer and Developers Sidekick allow you dynamically look at your data model including all your customizations.

I think you need to take a step back first, and work out the dataset you're interested in before trying to build the query for it, are you looking for information based on a particular account? a particular campaign, a particular opportunity ? what's the driving filter ?