Skip to main content
This page has instructions for making SQL selection queries against CockroachDB from various programming languages.

Before you begin

Before reading this page, do the following:
When running under the default SERIALIZABLE isolation level, your application should use a retry loop to handle transaction retry errors that can occur under contention.

Simple selects

For more information about how to use the built-in SQL client, see the cockroach sql reference docs.

Order results

To order the results of a query, use an ORDER BY clause. For example:
For reference documentation and more examples, see the ORDER BY syntax page.

Limit results

To limit the results of a query, use a LIMIT clause. For example:
For reference documentation and more examples, see the LIMIT/OFFSET syntax page.

Joins

The syntax for a selection query with a two-way join is shown below.
Join performance can be a big factor in your application’s performance. For more information about how to make sure your SQL performs well, see Optimize Statement Performance.

See also

Reference information related to this task: Other common tasks: