I am following salesforce's documentation here and trying to formulate a soql query for datacategories related to knowledge articles of type knowledge as follows:

SELECT Id, title (SELECT Id FROM DataCategorySelections) from Knowledge__kav where PublishStatus = 'Online'

I also tried adding the language (just in case), however, I keep getting an unknown error parsing query

I tried using the developer console, this is not critical or affecting me in any way, I just wanted to display id`s, titles and the datacategory associated to the articles. Is the documentation incorrect? or am I missing something? I would have thought that this being part of the documentation, under the module that introduces users to using SOSL and SOQL the example would work,

the first example works fine:

SELECT Id,ParentId FROM knowledge__DataCategorySelection

Additionally, if i run this:

string soql =('SELECT Id, title (SELECT Id FROM DataCategorySelections) from 
Knowledge__kav where PublishStatus = \'Online\'');
List<sObject> sobjList = Database.query(soql);

I get a Fatal Error:

EXCEPTION_THROWN [2]|System.QueryException: unexpected token: 'SELECT' FATAL_ERROR System.QueryException: unexpected token: 'SELECT' FATAL_ERROR AnonymousBlock: line 2, column 1

which leads me to believe that the documentation is inaccurate...


You missed the comma before your sub-query:

SELECT Id, Title (SELECT ...
//              ^ MISSING COMMA

Correct would be:

SELECT Id, Title, (SELECT ...
  • 1
    Indeed! however, this is how the documentation presents the SOQL. Additionally , after adding the comma, the console throws an implementation restriction Error, indicating to add the Language. not sure whats the best way to ask for salesforce to update their Doc. thanks for the pointer! – glls Apr 11 '17 at 18:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.