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

problem with my SOQL query
Hi friends,
I have a problem with my SOQL query.
Why can I not query the AccountId like this?
public Id idAcc {get;set;}
.
.
idAcc = [SELECT AccountId FROM Opportunity WHERE ID = :quo.OpportunityId LIMIT 1];
But with the following string is correct
Opportunity Opp = [SELECT AccountId FROM Opportunity WHERE ID = :quo.OpportunityId LIMIT 1];
I have a problem with my SOQL query.
Why can I not query the AccountId like this?
public Id idAcc {get;set;}
.
.
idAcc = [SELECT AccountId FROM Opportunity WHERE ID = :quo.OpportunityId LIMIT 1];
But with the following string is correct
Opportunity Opp = [SELECT AccountId FROM Opportunity WHERE ID = :quo.OpportunityId LIMIT 1];
Since SOQL returns list of SObjects. You can't assign List to a variable.
You can put egg(s) in the egg tray, but not the omlet.
You can get the Id like below.
public Id idAcc {get;set;}
.
.
idAcc = [SELECT AccountId FROM Opportunity WHERE ID = :quo.OpportunityId LIMIT 1].AccountId ;
Append .AccountId at the end of SOQL.
which is similar to
Opportunity Opp = [SELECT AccountId FROM Opportunity WHERE ID = :quo.OpportunityId LIMIT 1];
idAcc = Opp.AccountId;
Thankyou
You can choose it as best answer, if it answered your question.