ambigious column name in sql server -
hello i'm having ambiguous column name in m stored procedure payment .bid-id can resolve issue please?
set nocount on; select row_number() on ( order [paymentid] asc )as rownumber ,[paymentid] ,[name] ,[winningprice] ,[paymentdate] ,[payment.bidid] #results item inner join auction on item.itemid = auction.itemid inner join bid on auction.auctionid = bid.auctionid inner join payment on bid.bidid = payment.bidid (bid.status = 'paid') , (bid.buyerid = @buyer) select @recordcount = count(*) #results select * #results rownumber between(@pageindex -1) * @pagesize + 1 and(((@pageindex -1) * @pagesize + 1) + @pagesize) - 1 drop table #results end
good practice using aliases like:
set nocount on; select row_number() on ( order i.[paymentid] asc --which table belongs? put correct alias )as rownumber ,i.[paymentid] ,i.[name] ,i.[winningprice] ,i.[paymentdate] ,p.[bidid] #results item inner join auction on i.itemid = a.itemid inner join bid b on a.auctionid = b.auctionid inner join payment p on b.bidid = p.bidid (b.status = 'paid') , (b.buyerid = @buyer) select @recordcount = count(*) #results
Comments
Post a Comment