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
ankita vashisth 6ankita vashisth 6 

CAn anyone pls help me out in this I am getting unknwn parsing query error-- public static list<account> getaccount(List<Id> accountIds){ List<Account> acclst=[SELECT Id, Name, Email, Phone, AccountId FROM Contact WHERE AccountId in :accountIds];

RajeshPunjabiRajeshPunjabi
Hi Anikta,

You are trying to get account from contact table thats why you are getting parsing error.

If you need list of account from Contact you have to traverse through contact to get account list.


Try this:

for(Contact con:[Select Id, Account.Id, Account.Name, Acount.PesrsonEmail, Account.LastName From Contact Where Accountid IN:Accountid]){ acclist.add(con.Account); }

Regards,
Raj
 
Shubham_KumarShubham_Kumar
Hi Ankita
Your List "acclst" is of Account type but you are querying the records from Contact that`s why you are getting error.
Hope this helps you. Do let me know if you have any further questions.

P.S : Please mark this as the best Answer if this hepled you.

Thanks
Shubham Kumar
ankita vashisth 6ankita vashisth 6
thanks Raj..
RajeshPunjabiRajeshPunjabi
You are welcome; Please mark as resolve if you query is answered.