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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Help with query

Author  Topic 

ssunny
Posting Yak Master

133 Posts

Posted - 2008-11-19 : 12:27:02
Hey Guys,

Need help. I have 2 tables test and test1 as below.

test
------------

a int identity,
b varchar(100),
c varchar (100),
d varchar (100)


test1
----------------
e int identity,
f varchar(100),
g varchar(100)


Now column f in test1 could be either b or c from test. I want to select everything from test and test1.
Here's my query

select t.*,t1.* from test t
inner join test1 t1 on t.b = t1.f
inner join test1 t1 on t.c = t1.f

but it gives me an error

Server: Msg 1011, Level 15, State 1, Line 3
The correlation name 't1' is specified multiple times in a FROM clause.

Please advice.

Thanks.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-19 : 12:36:04
[code]select t.*,t1.*,t2.* from test t
inner join test1 t1 on t.b = t1.f
inner join test1 t2 on t.c = t2.f[/code]
Go to Top of Page

ssunny
Posting Yak Master

133 Posts

Posted - 2008-11-19 : 13:40:22
quote:
Originally posted by visakh16

select t.*,t1.*,t2.* from test t
inner join test1 t1 on t.b = t1.f
inner join test1 t2 on t.c = t2.f




I'm embarrassed.I dont know what I was thinking.
Thanks Visakh.
Go to Top of Page
   

- Advertisement -