user10123643
user10123643

Reputation: 11

Ambiguous column name error during select operation

I am getting the following error:

Msg 209, Level 16, State 1, Line 3 Ambiguous column name 'NUM_0'.

SELECT BPR_0, BPAPAY_0, BPYNAM_0, BPYADDLIG_0, NUM_0 -- and so on
  FROM PROD.SINVOICE, PROD.SINVOICED
  WHERE SINVOICE.NUM_0 = SINVOICED.NUM_0

enter image description here

Upvotes: 1

Views: 90

Answers (3)

Yogesh Sharma
Yogesh Sharma

Reputation: 50163

Qualify column name with table alise explicitly :

select sin.col, . . ., sind.col, . . ., c.col, . . .
from prod.sininvoice sin inner join
     prod.sininvoiced sind
     on sind.num_0 = sin_num_0 inner join
     prod.customer c 
     on . . .;

Upvotes: 1

Zaynul Abadin Tuhin
Zaynul Abadin Tuhin

Reputation: 32003

use Aliasproperly

Example

SELECT o.OrderID, o.OrderDate, c.CustomerName
FROM Customers AS c, Orders AS o
WHERE c.CustomerName="Around the Horn" AND c.CustomerID=o.CustomerID;

For Your case

select t1.col1,t1.col2 ....t1.coln from yourtable t1
inner join yourtable t2 on t1.num0=t2.num0

Upvotes: 0

ayush gorya
ayush gorya

Reputation: 11

Since Column "NUM_0" exists in both SINVOICE and SINVOICED tables,you need to specify the column with using alias.
For example SINVOICE.NUM_O or SINVOICED.NUM_O in you select statement depending upon from which table you want this column value.

Upvotes: 0

Related Questions