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
Learning Apex (OOP)Learning Apex (OOP) 

SOQL with "IN"

Hi,

How do you "read" (in plane English) this piece of code?
List<OpportunityShare> oppShareList = [select Id, OpportunityAccessLevel, RowCause from OpportunityShare where OpportunityId IN :opportunityIdList and RowCause = 'Team'];
My interpretation is...

Create a variable of the type List<OpportunityShare> which is called oppShareList and assign the following records to such list: all records (display the fields Id, OpportunityAccessLevel, etc...) FROM the table OpportunityShare WHERE ...????

I do not understand the code after the WHERE

Could someone explain?

Thank you very much.


 
Best Answer chosen by Learning Apex (OOP)
Shawn Reichner 29Shawn Reichner 29
So what this is saying is the following...

WHERE the Opportunity ID is in another list somewhere in your class or trigger which also has "Team" populated for the RowCause field. 

Does this help?

Shawn

All Answers

Shawn Reichner 29Shawn Reichner 29
So what this is saying is the following...

WHERE the Opportunity ID is in another list somewhere in your class or trigger which also has "Team" populated for the RowCause field. 

Does this help?

Shawn
This was selected as the best answer
Learning Apex (OOP)Learning Apex (OOP)
Hi Shawn,

Are you saying that the meaning is:

WHERE the field OpportunityId is included in the List OpportunityIdList AND the field RowCause (in the table OpportunityShare) is equal to 'Team' ?

Is this the correct interpretation of the SOQL code after WHERE ?

Thank you.