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
EricJRosenbergEricJRosenberg 

I need help with writing SOQL.

I know how to write SQL but and having trouble with creating a join with SOQL.  I am trying to connect the Opportunitiy table with the Campaign table.  I keep getting and error about creating a custom relationship.  It says 'If youa re attempting to use a custom relationshipbe sure to append the '_r' after the custom relationship name.  The Query I am using is

 

Select o.CampaignId, o.Name (Select c.Id from Campaigns) from Opportunity o

imuinoimuino

Try this

Select o.CampaignId, o.Name (Select c.Id from Campaigns__r) from Opportunity o

 

add the __r to Campaigns

Let me know if this works

EricJRosenbergEricJRosenberg

Nope still get the same error.

imuinoimuino

Try this

Select o.CampaignId, o.Name (Select c.Id from Campaigns__r c) from Opportunity o

You missed the c after Campaigns__r

THustonTHuston

you missed the , after o.Name