The reason behind the identifier could not be resolved error in your CosmosDB queries

When writing SQL queries to test them against your CosmosDB collections, chances are that your deal with the following error message:

Identifier XXX could not be resolved.

where XXX is the name of a property inside your collection. You could have for example the following query:

SELECT * FROM students WHERE firstname = 'Christos'

The reason for the error is that you forgot something in your query.

What you forgot to add is the name of the collection or the alias name to each property you use. Consider the following correct examples:

SELECT * FROM students WHERE students.firstname = 'Christos'

and here we use an alias for the name of our collection:

SELECT * FROM students AS s WHERE s.firstname = 'Christos'

As usual, a nice playground for your CosmosDB queries in this website

comments powered by Disqus