SQL Server 2012, error executing query

Asked

Viewed 64 times

3

Good afternoon, you guys

when executing 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'

appears the following message in SQL server 2012:

Nome da coluna 'PED_Numero' ambíguo.

What’s wrong with it?

1 answer

2


PED_Numero is a column that exists in pedido and in item.

To undo ambiguity, define 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'
  • 1

    Thanks buddy, it worked out here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.