# column reference "id" is ambiguous / ambiguous column name: id

Source: https://sqlstreak.com/sql/errors/column-reference-is-ambiguous · Tested on PostgreSQL 18.6 and SQLite 3.54.1; results generated 2026-11-22.


**Short answer:** After a join, more than one table has a column with that name, so the database doesn't know which one you mean. Prefix the column with its table or alias: `o.id`, `c.id`.

## The exact messages

- PostgreSQL: `ERROR: column reference "id" is ambiguous`
- SQLite: `ambiguous column name: id`

## How PostgreSQL prints it

```
ERROR:  column reference "id" is ambiguous
LINE 1: SELECT id, name
               ^
```

## Why it happens

### Two joined tables share a column name

`id`, `name` and `created_at` are the usual suspects: almost every table has them.

### It can appear anywhere

SELECT, WHERE, GROUP BY, ORDER BY and ON can all trigger it. Qualify the column in every place it appears.

## The broken query

```sql
SELECT id, name
FROM orders o
JOIN customers c ON c.id = o.customer_id;
```

## The fix

```sql
SELECT o.id, c.name
FROM orders o
JOIN customers c ON c.id = o.customer_id;
```

Give every table a short alias and prefix every column in multi-table queries. It also makes the query easier to read.

| id | name |
| --- | --- |
| 1 | Maya Ortiz |
| 2 | Jonah Reed |
| 3 | Maya Ortiz |
| 4 | Priya Nair |
| 5 | Tomás Herrera |
| 6 | Ellie Park |

(6 of 17 rows)
