For questions related to the syntax of and issues with Sitecore Query notation
You can use Sitecore query to select items that meet specific criteria from a Sitecore database. Sitecore query uses a syntax based on XPath to access something like an XML representation of a Sitecore database.
Unlike SQL queries, this technique abstracts the underlying database technology; like most things in Sitecore, Sitecore queries that you develop with one database technology (such as Microsoft SQL Server) work without modification in Sitecore solutions that use other database technologies (such as Oracle).
https://community.sitecore.net/technical_blogs/b/sitecorejohn_blog/posts/sitecore-query-cheat-sheet