# operator does not exist: integer = text

Source: https://sqlstreak.com/sql/errors/operator-does-not-exist-integer-text · Tested on PostgreSQL 18.6 and SQLite 3.54.1; results generated 2026-11-22.


**Short answer:** You're comparing (or joining) a number column with a text column. PostgreSQL doesn't convert between them automatically. Usually you've picked the wrong column; otherwise cast one side explicitly, e.g. `CAST(x AS integer)`.

## The exact messages

- PostgreSQL: `ERROR: operator does not exist: integer = text`

## How PostgreSQL prints it

```
ERROR:  operator does not exist: integer = text
LINE 3: JOIN adoption_requests r ON p.id = r.pet_name;
                                         ^
HINT:  No operator matches the given name and argument types. You might need to add explicit type casts.
```

## Why it happens

### Joining on the wrong column

Here `pets.id` (a number) is joined to `adoption_requests.pet_name` (text). The intended match was name to name.

### IDs stored as text in one table

Imported data often stores numbers as text. Cast one side: `ON p.id = CAST(r.pet_id AS integer)`, or better, fix the column type.

### Using + to join strings

`name + ' the ' + species` gives the related error `operator does not exist: text + unknown`. SQL concatenates text with `||`.

## The broken query

```sql
SELECT p.name, r.email
FROM pets p
JOIN adoption_requests r ON p.id = r.pet_name;
```

## The fix

```sql
SELECT p.name, r.email
FROM pets p
JOIN adoption_requests r
  ON LOWER(TRIM(r.pet_name)) = LOWER(p.name);
```

Join text to text. Because visitors typed the names, trimming spaces and lowering case makes the match reliable.

| name | email |
| --- | --- |
| Biscuit | Ana@Mail.com |
| Biscuit | ana@mail.com |
| Bruno | GUS@mail.com  |
| Bruno | gus@mail.com |
| Kiwi | hana@mail.com |
| Luna | cara@mail.com |

(6 of 12 rows)

## What SQLite does instead

SQLite compares the two anyway and quietly returns no matches, so the bug hides behind an empty result instead of an error.
