# Find rows

> Look up rows in a collection.

Source: https://docs.buildcord.dev/nodes/variables-and-data/find-rows/

`data.query` finds rows in a [collection](https://docs.buildcord.dev/concepts/data#collections) and reads the first into the run.

## Settings

| Setting | What it does |
| --- | --- |
| Collection | The collection to search. |
| Where | A condition, such as `user = {user.id}`. Empty matches every row. |
| Sorted by | A column, then `desc` for largest first, such as `score desc`. Empty keeps the oldest first. |
| Limit | How many rows to find. The default is 1. |
| Read the row as | The name to read the row under. Its columns are `{row.column}` unless you name it. |

## Ways out

| Way out | Taken when |
| --- | --- |
| `Found` | At least one row matched. |
| `Nothing found` | None did. |

## Produces

| Token | Value |
| --- | --- |
| `{row.id}` | The number of the row found |
| `{row.column}` | Each column of the row |
| `{rows.count}` | How many rows matched |
| `{rows.all}` | Every row found, up to the limit, as a list. [Run code](https://docs.buildcord.dev/nodes/integrations/run-code) reads it as `ctx.rows.all` |
| `{name.count}`, `{name.all}` | The same, when the row is named. Later finds don't replace them |

## Notes

- Name the row with **Read the row as** when a later step finds a different row and you still need this one.
- To work with several finds in one Run code step, name each one. Find `user = {user.id}` as `mine` and `team = {option.team}` as `team`, then read `ctx.mine.all` and `ctx.team.all`.
- The canvas shows `Collection where condition`.

## Example

Find the member's open ticket with `user = {user.id} and status = open`. If **Nothing found**, create one.

## Related

- [For each row](https://docs.buildcord.dev/nodes/variables-and-data/for-each-row)
- [Add row](https://docs.buildcord.dev/nodes/variables-and-data/add-row)
