Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Join table

Author  Topic 

lagarto
Starting Member

4 Posts

Posted - 2008-03-03 : 21:25:12
I want to select a few fields from table Detail, and then one field from the table Ink, but when i do this the sql server says: Ambiguous column name 'inkModel'. Can anyone help me out?


SELECT userDeptName, userDeptCategory, inkModel, quantity, dateOfTheRequest, AprovedBy FROM Detail

INNER JOIN Ink
ON
Detail.inkModel = Ink.inkPrice
WHERE
Ink.inkPrice = 1200.00

dataguru1971
Master Smack Fu Yak Hacker

1464 Posts

Posted - 2008-03-03 : 21:27:13
you have to specify which table inkModel is coming from. It is ambiguous because it could come from either table (even though they are the same due to the join)

SELECT userDeptName, userDeptCategory, ink.inkModel, quantity, dateOfTheRequest, AprovedBy FROM Detail
INNER JOIN Ink
ON
Detail.inkModel = Ink.inkPrice
WHERE Ink.inkPrice = 1200.00




Poor planning on your part does not constitute an emergency on my part.

Go to Top of Page

lagarto
Starting Member

4 Posts

Posted - 2008-03-03 : 21:52:22
Error converting data type varchar to numeric.

thats what is comming up now :/
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-03-03 : 21:57:27
What's the data type of Ink.inkPrice?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

lagarto
Starting Member

4 Posts

Posted - 2008-03-03 : 22:00:23
decimal(6,2)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-03-03 : 22:09:55
What data type is Detail.inkModel?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

lagarto
Starting Member

4 Posts

Posted - 2008-03-03 : 22:27:44
varchar :/
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-03-03 : 22:33:58
And do you have any data in that column that can't convert to decimal(6,2)? You are joining those two columns together, so they need to be compatible.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -