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)
 Plz Help join Query...

Author  Topic 

brr_hyd
Starting Member

4 Posts

Posted - 2010-01-22 : 06:54:10
hi all,

iam new to sql queries. iwant a query plz help. here my requirement is, i have 3 tables

Table 1
---------------- --------------
StockDesc stockid
------------------ --------------
ABC s1
DEF s3
GHI s5



Table 2
---------------
stockid
---------------
s2
s4
s6


Table 3
--------------- ---------------
FundCode citiCode
--------------- ----------------
s1 A1
s4 A2
s6 A3



so here 1st table stock ids, and 2nd table stock ids are in 3rd table fundcode(fundcode contain table a, table b stockids) so here i have to catch, 3rd table citicode based on 1st table stockid, and 2nd table stockid, with compare 3rd table fundcode.

My out shouldbe like this.

---------------------------------------------------------------------
StockDesc citiCode
---------------------------------------------------------------------
ABC A1
DEF A2
GHI A3


plz help how to write query for this.

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2010-01-22 : 07:00:41
So, how would you start? If you actually want to learn, it is worth giving it a try and then we can help you from there.

Also think about how you join Table3 to Table2 as these fields are different by the looks of things. How would A1 join to ABC?

Check your data and then look up JOIN in Books Online.
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-01-22 : 07:04:48
So Table1 and Table2 are in an "order" that they should be matched on? 1st row in Table1 matches 1st row in Table2?

If so: do you have Row Number in the table that can be used to make the match, or something else common to Table1 and Table2

Or maybe I have misunderstood?
Go to Top of Page
   

- Advertisement -