+ Start a Discussion
Gaurav Jain 67Gaurav Jain 67 

Unable to compare fields from same Object in SOQL

My scenario is (I need to Add a text 'Opportunity' to end of the Opportunity Name where Opportunity Name is equal to Account Name).  I am using following code,  but getting error on line 5 that "can compare a String to Account " .. The Field Name for Account NAme is Account and thus I am comparing that ..

LIST<opportunity> OppList = New LIST<opportunity>();
for(Opportunity O: [select id , name from Opportunity ])
O.Name=O.Name + 'Opportunity';
Update OppList;

Please help
Gaurav Jain 67Gaurav Jain 67
SOLVED: Used O.Account.Name  instead of O.Account