---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.4
alternate:
  - https://ydb.tech/docs/en/reference/ydb-cli/scan-query.md
  - https://ydb.tech/docs/ru/reference/ydb-cli/scan-query.md
sourcePath: en/core/reference/ydb-cli/scan-query.md
---
> **Documentation Index:** Fetch the complete configuration index at https://ydb.tech/docs/en/llms.txt

<!-- source: en/reference/ydb-cli/commands/_includes/scan-query.md -->
# Running scan queries

<!-- source: en/_includes/scan_query_deprecated_warning.md -->
{% note warning %}

This functionality is deprecated. Use standard query execution methods.
See [Query execution](https://ydb.tech/docs/en/reference/ydb-cli/sql.md).

{% endnote %}
<!-- endsource: en/_includes/scan_query_deprecated_warning.md -->

To run a query via [Scan Queries](https://ydb.tech/docs/en/concepts/query_execution/scan_query.md) using YDB CLI, add the `-t scan` flag to the `ydb table query execute` command.

Run a query against the data:

```bash
ydb table query execute -t scan \
 --query "SELECT season_id, episode_id, title \
 FROM episodes \
 WHERE series_id = 1 AND season_id > 1 \
 ORDER BY season_id, episode_id \
 LIMIT 3"
```

Where:

* `--query` — query text.

Result:

```text
┌───────────┬────────────┬──────────────────────────────┐
| season_id | episode_id | title |
├───────────┼────────────┼──────────────────────────────┤
| 2 | 1 | "The Work Outing" |
├───────────┼────────────┼──────────────────────────────┤
| 2 | 2 | "Return of the Golden Child" |
├───────────┼────────────┼──────────────────────────────┤
| 2 | 3 | "Moss and the German" |
└───────────┴────────────┴──────────────────────────────┘
```
<!-- endsource: en/reference/ydb-cli/commands/_includes/scan-query.md -->
