I'm trying to create a SOQL query that pulls records from an Object based on if there are any results from another linked object. Here is sort of what I am trying to do.
SELECT id, casenumber FROM case WHERE count(SELECT ContentDocumentId FROM ContentDocumentLink WHERE LinkedEntityId = case.id) > 0
This returns the error, MALFORMED_QUERY: casenumber FROM case WHERE count(SELECT ContentDocumentId FROM ContentDocumentLink ^ ERROR at Row:1:Column:44 unexpected token: 'SELECT'
After a few attempts at trying to make this work I am not sure what else try. I know SOQL has some limitations but I am unsure if this is one of them. Anyone have insight? Thanks.