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
 joins and returning rows

Author  Topic 

kevison
Starting Member

5 Posts

Posted - 2008-03-07 : 11:13:25
Using MS SQLServer 2000

Is there a way to create a query that will return only 1 row within a join for example:

select a,b,c,d
from tbl1
inner join tbl2 on top 1 tbl2.a = tbl1.a <-- return only the top record here...

I dont have too much of a problem with joins... however I was wondering if there was a mechanism to just specify what would be the top most record from a join clause.

thanks
Kevin

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-03-07 : 11:19:16
TOP clause is applicable while projecting data not while joining tables.

SELECT TOP 1 *
from t1 join t2....


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -