Sunday, March 11, 2012

advance subquery question

i wanT a sql select statement like this
select a,b,c from table 1
where x= alias.x and y=alias.y
(select x,y from table2 ) as alias
dont wanna use cursor
thanksTry this:
select a,b,c
from table1 AS t1
INNER JOIN
(select x,y from table2 ) as alias
ON t1.x= alias.x and t1.y=alias.y
HTH,
Vyas, MVP (SQL Server)
SQL Server Articles and Code Samples @. http://vyaskn.tripod.com/
"joeydj" <joeydj@.discussions.microsoft.com> wrote in message
news:B5D657C6-ACDE-4DDD-BB0E-E23C78E811DE@.microsoft.com...
i wanT a sql select statement like this
select a,b,c from table 1
where x= alias.x and y=alias.y
(select x,y from table2 ) as alias
dont wanna use cursor
thanks|||select
table1.a,
table1.b,
table1.c
from
table1
INNER JOIN
table2 as alias
on table1.x = alias.x
and table1.y = alias.y
Mike Epprecht, Microsoft SQL Server MVP
Zurich, Switzerland
MVP Program: http://www.microsoft.com/mvp
Blog: http://www.msmvps.com/epprecht/
"joeydj" wrote:

> i wanT a sql select statement like this
> select a,b,c from table 1
> where x= alias.x and y=alias.y
> (select x,y from table2 ) as alias
> dont wanna use cursor
> thanks
>|||select table1.a,table1.b,table1.c from table1
join table2
on table1.x = table2.x and table1.y = table2.y
"joeydj" wrote:

> i wanT a sql select statement like this
> select a,b,c from table 1
> where x= alias.x and y=alias.y
> (select x,y from table2 ) as alias
> dont wanna use cursor
> thanks
>

No comments:

Post a Comment