[SalesForce] fetching account lookup value on case in inner query

I am fetching account lookup value in class using inner soql query but it throwing error

Compile Error: No such column 'Account' on entity 'Case'. If you are attempting to use a custom field, be sure to append the '__c' after the custom field name. Please reference your WSDL or the describe call for the appropriate names"

 String con_Email = envelope.fromAddress;

    //write soql and checking sender email & existing email of contact same
    List<Contact> conList = [SELECT Id, AccountID, Block_Email__c, Email, (SELECT Account FROM cases) FROM contact WHERE email =: con_Email LIMIT 1];

enter image description here

Best Answer

The actual field API Name is AccountId, as you can see in the documentation for the Case object. So the correct sub-query would be:

(SELECT AccountId FROM Cases)

You can pull other fields through the Account reference, but you can't just pull the object itself. For example this query will compile and run just fine:

(SELECT Account.Name FROM Cases)
Related Topic