# 53: TYPE_MISMATCH (code 53)

> A value that cannot be converted to the other side's type met a comparison or an IN list.

Source: https://sqlly.app/errors/clickhouse/type-mismatch
Last updated: 2026-11-30
License: Text and data [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/) (credit SQLly, sqlly.app); code and SQL snippets [MIT](https://opensource.org/license/mit). [Details](https://sqlly.app/license).
Note: Quoted error message text belongs to its database vendor.

- Error code: `53`
- Name: `TYPE_MISMATCH`
- Category: Tables, columns and metadata

Error message:

```text
Type mismatch in IN or VALUES section: {left_type} vs {right_type}
```

## What it means

`TYPE_MISMATCH` (53) is raised when comparison or assignment needs a common type and none exists, for example a string that cannot convert to UInt64. Array(Tuple) against String fails with CANNOT_READ_ARRAY_FROM_TEXT (130) instead. It differs from `ILLEGAL_TYPE_OF_ARGUMENT` (43), which complains about a function argument.

## Common causes

- Comparing a numeric column to a quoted string literal from application code.
- An IN list literal holding a value that cannot convert to the left side's type.
- INSERT data whose columns do not match the declared schema; unparsable values raise 6 (CANNOT_PARSE_TEXT) instead.

## How to fix it

1. Cast explicitly so the intent is on record.

   ```sql
   SELECT * FROM events WHERE id = toUInt64('42');
   ```
2. Match the IN subquery type to the left column.

   ```sql
   SELECT * FROM events WHERE user_id IN (SELECT toUInt64(external_id) FROM mapping);
   ```
3. Insert with explicit types rather than relying on inference.

   ```sql
   INSERT INTO events (user_id) SELECT toUInt64(col) FROM staging;
   ```

## Reproduce it safely

```sql
SELECT 1 WHERE 1 IN ['a']; raises TYPE_MISMATCH between String and UInt64.
```

## How SQLly helps

SQLly's schema tree prints each column's ClickHouse type next to its name, so a String column compared to a bare number literal is visible before you run.

## Questions

### Does ClickHouse ever compare String and numbers implicitly?

It converts when the string parses, so WHERE id = '42' matches a UInt64 column. It raises 53 only when the string cannot be converted, such as 'abc'. Cast explicitly anyway so the intent is on record.

### Why does the message mention IN?

IN list literals raise it (1 IN ['a'] gives 53). An IN subquery with a mismatched type does not raise here, and a bad INSERT value raises 6 (CANNOT_PARSE_TEXT) instead.

## Related errors

- [`62`](https://sqlly.app/errors/clickhouse/syntax-error): SYNTAX_ERROR (code 62)
- [`20`](https://sqlly.app/errors/clickhouse/number-of-columns-doesnt-match): NUMBER_OF_COLUMNS_DOESNT_MATCH (code 20)

The code and message text are from the [ClickHouse documentation (system.errors)](https://clickhouse.com/docs/en/operations/system-tables/errors).
