# SQLCODE -203: Ambiguous column reference

Source: https://wndsoftware.com/mainframe-errors/sqlcode-203

### SQLCODE -203: Ambiguous column reference

SQLCODE -203 (SQLSTATE 42702) means a column name in the statement could refer to more than one column, usually because two tables in the FROM clause both have a column with that name. Db2 won't guess which one you meant.


#### Other names for this code

Also written as `SQL -203`, `SQLCODE=-203`, `SQLCODE = -203`, `db2 -203`, `sqlstate 42702`, `SQL0203N`, `reference to column is ambiguous`.


### What it means

When a query reads more than one table, Db2 matches each unqualified column name against all of them. If the name exists in only one, there is no problem. If it exists in two or more, Db2 can't tell which you mean, so it rejects the statement with -203 and names the column.

Joins on a shared key are the classic case. If ORDERS and CUSTOMER both have CUST_NO, then `SELECT CUST_NO` or `WHERE CUST_NO = :WS-CUST` is ambiguous, even though the two columns hold the same value after the join. Db2 doesn't know that and doesn't assume it.

A query can also become ambiguous without being changed. If a column is added to one of the tables and it has the same name as a column in another table of the join, the next bind or prepare fails with -203.


### Common causes

- A join where both tables have a column with the same name, and the statement uses it unqualified.
- A self-join where a column is written without the correlation name, so Db2 can't tell which copy of the table it belongs to.
- A column added to one table that now clashes with a column in another table of an existing join.
- A nested table expression that has two columns with the same name. Even a reference qualified with its correlation name is then ambiguous.
- In a CREATE TRIGGER, a column of the triggering table is used without the OLD or NEW correlation name for the transition variable.


### How to find the problem

- Take the column name from the `DSNT408I` message or SQLERRMC.
- List the tables and views in the FROM clause and check which ones have that column, for example with `SELECT TBNAME FROM SYSIBM.SYSCOLUMNS WHERE NAME = 'CUST_NO' AND TBCREATOR = 'PAYPROD'`.
- If the query worked before, check whether a column was recently added to one of the tables.
- For static SQL, the bind output gives the statement number in the DBRM.


### How to fix it

- Qualify the column with a correlation name, as in `SELECT O.CUST_NO FROM ORDERS O JOIN CUSTOMER C ON O.CUST_NO = C.CUST_NO`.
- Give every table in a join a short correlation name, and use it on every column. Then a new column can't break the query.
- In a self-join, use different correlation names for each copy of the table.
- If a nested table expression returns two columns with the same name, rename one of them with AS so each name is unique.
- Rebind or re-prepare after the change.


### What it looks like


```text
DSNT408I SQLCODE = -203, ERROR:  A REFERENCE TO COLUMN CUST_NO IS AMBIGUOUS
DSNT418I SQLSTATE   = 42702 SQLSTATE RETURN CODE
```


### IBM documentation

[IBM documentation: -203](https://www.ibm.com/docs/en/db2-for-zos/13.0.0?topic=codes-203). Use the documentation for your installed release.

[Report a correction to WND Software](https://wndsoftware.com/contact#message).

Technical reviewer: [Albert Joseph](https://wndsoftware.com/authors/albert-joseph), WND Software.

Last reviewed 2026-10-18 by the WND Software team. Written in our own words. For the full reference, check IBM’s Db2 for z/OS documentation for your release.


### Related codes

[SQLCODE -206 Column name not valid Read →](https://wndsoftware.com/mainframe-errors/sqlcode-206)
[SQLCODE -205 Column not in the named table Read →](https://wndsoftware.com/mainframe-errors/sqlcode-205)
[SQLCODE -204 Undefined object name Read →](https://wndsoftware.com/mainframe-errors/sqlcode-204)
[SQLCODE -208 ORDER BY column not in result table Read →](https://wndsoftware.com/mainframe-errors/sqlcode-208)

### Questions


#### Why is it ambiguous when both columns hold the same value?

Db2 resolves names before it looks at data. Two columns with the same name in different tables are different columns, even when the join makes their values equal.


#### Why did the query break when no one changed it?

A column was probably added to one of the tables with a name another table in the join already uses. The next bind or prepare then finds two matches.


#### Is it the same on Db2 for LUW?

Yes. SQL0203N has SQLSTATE 42702 and the same meaning.

[Db2 SQLCODEs](https://wndsoftware.com/mainframe-errors/db2-sqlcodes) · [SQLCODE -199](https://wndsoftware.com/mainframe-errors/sqlcode-199) · [SQLCODE -204](https://wndsoftware.com/mainframe-errors/sqlcode-204)

[← All error codes](https://wndsoftware.com/mainframe-errors/)
