SQL Server 2012, error executing query

3

Good afternoon, people

When you run the query below:

select PRO_Descricao, PED_Numero
from pedido p, item i, produto pr
where p.PED_Numero = i.PED_Numero
and i.PRO_Codigo = pr.PRO_Codigo
and PRO_Descricao >= 'SA'
and pro_descricao < 'SB'

The following message appears in SQL Server 2012:

Nome da coluna 'PED_Numero' ambíguo.

What's wrong?

    
asked by anonymous 29.10.2015 / 21:22

1 answer

2

PED_Numero is a column that exists in pedido and item .

To undo the ambiguity, set table identifiers for the columns and for the tables involved:

select pr.PRO_Descricao, p.PED_Numero
from pedido p, item i, produto pr
where p.PED_Numero = i.PED_Numero
and i.PRO_Codigo = pr.PRO_Codigo
and pr.PRO_Descricao >= 'SA'
and pr.pro_descricao < 'SB'
    
29.10.2015 / 21:24