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
 Field Name is defined multiple times

Author  Topic 

msvdm
Starting Member

17 Posts

Posted - 2011-08-19 : 16:00:32

SELECT Z.* FROM
(
(SELECT Pol,ba,Opt,Unit,Farm,Map,Unit,Sub FROM Pol.PolUn
AS A
Inner JOIN policy.PolV AS B
ON A.Pol=B.Pol))Z

The INNER JOIN doesnt work but the query is executed without the inner join...When I change query it says that Pol is defined multiple times.

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2011-08-19 : 16:05:28
It probalby means that the tables Pol.PpolUn and policy.PolV each have a column named Pol. So which one do you want A.Pol or B.Pol?
Go to Top of Page

msvdm
Starting Member

17 Posts

Posted - 2011-08-19 : 16:16:48
It is the same column in both the tables
Go to Top of Page

msvdm
Starting Member

17 Posts

Posted - 2011-08-19 : 17:31:51
Pol is the common column in both the tables ...I am joining both the tables based on this common column, Suppose if I take the column from A then I am able to get the mentioned columns from A but couldnt get the the data from B..i.e the inner join part is not shown up.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-08-19 : 23:17:54
[code]
SELECT Z.*
FROM
(
SELECT A.Pol,
ba,
Opt,
Unit,
Farm,
Map,
Unit,
Sub
FROM Pol.PolUn AS A
Inner JOIN policy.PolV AS B ON A.Pol=B.Pol
) Z
[/code]

It is good practice to prefix column name with the table name or table alias.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -