Learn the motive and how to get to the bottom of the ORA-00960 error message in Oracle.
Description
When you encounter an ORA-00960 error, the following error message will appear:
ORA-00960: ambiguous column naming in select list
Cause
You tried to execute a SELECT statement the place a column with the identical identify is listed in the SELECT list and then ambiguously defined within the ORDER BY clause.
Resolution
The option(s) to resolve this Oracle error are:
Option #1
Try prefixing the column that is ambiguously defined in the ORDER BY clause with the desk name.
For example, if you tried to execute the following SELECT statement:
SELECT suppliers.supplier_id, orders.supplier_id
FROM suppliers
INNER JOIN orders
ON suppliers.supplier_id = orders.supplier_id
ORDER BY supplier_id;
You would receive the following error message:
You should correct this error through prefixing the supplier_id column in the ORDER BY clause with both provider or orders.
For example:
SELECT suppliers.supplier_id, orders.supplier_id
FROM suppliers
INNER JOIN orders
ON suppliers.supplier_id = orders.supplier_id
ORDER BY suppliers.supplier_id;
OR
SELECT suppliers.supplier_id, orders.supplier_id
FROM suppliers
INNER JOIN orders
ON suppliers.supplier_id = orders.supplier_id
ORDER BY orders.supplier_id;
Leave a Review