# Clear Matching Row Data

> Find rows matching a query and clear selected columns from all of them.

- ID: `db_clear_matching_row_data`
- Type: Block
- Category: [Databases](https://inventor.bot/docs/reference/blocks/databases.md)

**Inputs**

| Name | Required | Description | Value |
| --- | --- | --- | --- |
| `database_id` | yes | Select the database containing the rows. |  |
| `limit` |  | Maximum number of rows to clear (default: 100, max: 1000). | e.g. `"100"` |
| `columns` | yes | Comma-separated column names or column IDs to clear. System columns cannot be cleared. | e.g. `"name, points"` |
| `query_json` |  | Define filters to find the rows to clear. | JSON text, format below |

**`query_json` format**: JSON text of type `DatabaseQuery`. Fields marked `?` are optional.

```ts
type DatabaseQuery = {
	where?: FilterGroup
	sort?: SortClause[]
	limit?: number
	offset?: number
}

type FilterGroup = {
	logic: string // "and" or "or"
	conditions: FilterCondition[]
}

type FilterCondition = {
	type: string // "comparison" or "group"
	columnId?: string // comparison only
	operator?: string // comparison only: eq, neq, gt, gte, lt, lte, contains, not_contains, starts_with, ends_with, is_empty, is_not_empty
	value?: string // comparison only
	group?: FilterGroup // group only
}

type SortClause = {
	columnId: string
	direction: string // "asc", "desc" or "random"
}
```

**Outputs**

| Name | Description | Value |
| --- | --- | --- |
| `updated_count` | The number of rows that were cleared. | e.g. `"5"` |

**Example**

```go
clearMatchingRowData := db_clear_matching_row_data(Args{database_id: "...", columns: "name, points"})
send_text_message(Args{
	channel_id:      trigger.channel_id,
	message_content: "Updated Count: " + clearMatchingRowData.updated_count,
})
```