| | |
Joining two tables
Please support our MS SQL advertiser: Intel Parallel Studio Home
Thread Solved |
•
•
Join Date: Nov 2008
Posts: 2
Reputation:
Solved Threads: 0
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
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
•
•
Join Date: Aug 2008
Posts: 1,160
Reputation:
Solved Threads: 137
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?
are you sure this is what you are wanting?
Custom Application & Software Development
www.houseshark.net
www.houseshark.net
•
•
Join Date: Feb 2008
Posts: 41
Reputation:
Solved Threads: 13
Try this command:
MS SQL Syntax (Toggle Plain Text)
SELECT T1.idx, T2.idy, T2.u FROM Table1 T1 RIGHT JOIN Table2 T2 ON T1.idy = T2.Idy AND T1.idx = 'one'
Hence Wijaya
www.ex-Soft.tk
www.ex-Soft.tk
![]() |
Similar Threads
- Joining two tables in VB 6 (Visual Basic 4 / 5 / 6)
- Join multiple tables (VB.NET)
- Joining 4 or more tables (MySQL)
- ..joining 2 tables?=A tuf one....can U crack this ? (VB.NET)
- Need Help Joining 3 tables (MySQL)
Other Threads in the MS SQL Forum
- Previous Thread: Transfer of data
- Next Thread: Need Advice please
| Thread Tools | Search this Thread |






