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 2005 Forums
 Transact-SQL (2005)
 Many to 1 Relationship !!!!!!

Author  Topic 

haroon2k9
Constraint Violating Yak Guru

328 Posts

Posted - 2010-02-10 : 08:15:44
Hi,

Table1

id locationame
1 A
2 B
3 C

Table2

id locationid
1 1
2 3
3 2
4 1

SELECT T2.ID,T1.FNAME
FROM Table1 T1
INNER JOIN Table2 T2
ON T1.ID=T2.FNAMEID

O/p
id locationame
1 A
2 C
3 B
4 A

The above qry works ok..
please do let me know the best way?????

Thanks.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-10 : 08:22:32
what do you mean by best way?

------------------------------------------------------------------------------------------------------
SQL Server MVP
Go to Top of Page

haroon2k9
Constraint Violating Yak Guru

328 Posts

Posted - 2010-02-10 : 08:53:17
quote:

what do you mean by best way?


for many to 1 relation ship,i used INNER JOIN to get the required result.Ok.
INNER JOIN is ok(The query which i have used above) for this kind of scnerio or please advice / suggest me your approach for this solution..
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-10 : 09:01:28
I would have also prefered to use INNER JOIN in above scenario

------------------------------------------------------------------------------------------------------
SQL Server MVP
Go to Top of Page

haroon2k9
Constraint Violating Yak Guru

328 Posts

Posted - 2010-02-10 : 09:02:39
Ok.Thanks Visakh16.
Go to Top of Page
   

- Advertisement -