View query syntax
The View query language provides a SQL-like syntax for querying and retrieving data from your views. This page provides an overview of the language features and serves as an entry point to the detailed syntax documentation.
Overview
The View query language enables you to:
-
Select specific data fields or entire objects
-
Filter results based on conditions
-
Join data from multiple tables
-
Sort and limit results
-
Create hierarchical data structures
-
Paginate large result sets
Core query components
For the complete query structure and syntax, see Query.
Operators
-
Operators overview - All available operators
-
Comparison operators - =, !=, >, <, etc.
-
Logical operators - AND, OR, NOT
-
IN - Testing membership in a list
-
= ANY - Testing membership in an array
-
LIKE - Pattern matching
-
IS NULL / IS NOT NULL - Testing for null values
Functions
-
Functions overview - All available functions
-
collect() - Creating collections from grouped rows
-
count(*) - Counting rows
-
DISTINCT - Removing duplicates
-
text_search() - Advanced text searching
Pagination
-
Pagination - Pagination approaches
-
OFFSET - Skipping results
-
LIMIT - Limiting result count
Example queries
Here are a few examples of common query patterns:
SELECT * FROM products
WHERE category = 'Electronics' AND price < 500
ORDER BY price ASC
SELECT * AS products, next_page_token() AS nextPageToken
FROM products
OFFSET page_token_offset(:pageToken)
LIMIT 10
SELECT category, collect(*) AS products
FROM products
GROUP BY category
Start with the Query reference for more examples and detailed syntax information.
Related concepts
-
Data types - Types supported in views
-
Result mapping - How queries map to Java types
-
Table updaters - Defining view tables