You can use below query in trigger to fetch the cases related to Account
Below query when you want to fetch data from Account- SELECT Name, (SELECT Id, AccountId, CaseNumber FROM Cases) FROM Account WHERE Id IN (SELECT AccountId FROM Case)
Alternative would be on Case Object- SELECT Id, AccountId, Account.Name, CaseNumber FROM Case WHERE AccountId != ''
Adding an image from the developer console from the first query-
You can use below query in trigger to fetch the cases related to Account
Below query when you want to fetch data from Account-
SELECT Name, (SELECT Id, AccountId, CaseNumber FROM Cases) FROM Account WHERE Id IN (SELECT AccountId FROM Case)
Alternative would be on Case Object-
SELECT Id, AccountId, Account.Name, CaseNumber FROM Case WHERE AccountId != ''
Adding an image from the developer console from the first query-
Regards,
Sangeet
Will you please choose answer as best, If you found that my answer is relevant for you.
Which helps for other.
Regards,
Sangeet