Joining two tables

Please support our MS SQL advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Nov 2008
Posts: 2
Reputation: rebeka.six is an unknown quantity at this point 
Solved Threads: 0
rebeka.six rebeka.six is offline Offline
Newbie Poster

Joining two tables

 
0
  #1
Nov 22nd, 2008
I need help with joining these two tables:

Table1

idx idy
---------
one 1
two 2
tree 3


Table2

idy u
-------
1 a
2 b
3 c
4 d
5 e
6 f

I want to show rows from the Table1 that have idx=one joined with all the rows from Table2.
So, I want to join these two tables so that Table1.idy=Table2.idy and Table1.idx=one
The result table should look like this.

Result table:

idx idy u
--------------
one 1 a
NULL 2 b
NULL 3 c
NULL 4 d
NULL 5 e
NULL 6 f

Could someone help me with this?
Thanks.
Rebeka
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,160
Reputation: dickersonka will become famous soon enough dickersonka will become famous soon enough 
Solved Threads: 137
dickersonka dickersonka is offline Offline
Veteran Poster

Re: Joining two tables

 
0
  #2
Nov 23rd, 2008
i don't see how you are expecting idx = NULL for 2-6, when you have both entries for idy in both tables

are you sure this is what you are wanting?
Custom Application & Software Development
www.houseshark.net
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 40
Reputation: huangzhi is an unknown quantity at this point 
Solved Threads: 13
huangzhi huangzhi is offline Offline
Light Poster

Re: Joining two tables

 
0
  #3
Nov 24th, 2008
Try this command:
  1. SELECT T1.idx, T2.idy, T2.u
  2. FROM Table1 T1 RIGHT JOIN Table2 T2 ON
  3. T1.idy = T2.Idy AND T1.idx = 'one'
Hence Wijaya
www.ex-Soft.tk
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 2
Reputation: rebeka.six is an unknown quantity at this point 
Solved Threads: 0
rebeka.six rebeka.six is offline Offline
Newbie Poster

Re: Joining two tables

 
0
  #4
Nov 24th, 2008
Hi,

Works perfectly!
Thanks,

Rebeka
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the MS SQL Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC