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.
| Author |
Topic |
|
dcarva
Posting Yak Master
140 Posts |
Posted - 2003-09-28 : 19:15:23
|
| Hello, I can easily join two tables if ONE value in a table matches a value in another. (such as when you have an ORDERS and ORDERDETAILS table and both tables can be joined by the OrderId field)But I have a situation where I need to join one table with another table on more than one column. How can I do this? I have no idea.Say you have two tables. (table1 and table2) Each table has three category fields. (represents a node in a tree) I need to join both tables where all three category fields in table1 match all three category fields in table2.Any help is appreciated. Thanks! |
|
|
dcarva
Posting Yak Master
140 Posts |
Posted - 2003-09-28 : 19:52:01
|
| I think there is a way to create a primary key based on three fields. This might do it. |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-09-28 : 19:58:49
|
| INNER JOINtable2ONtable1.col1 = table2.col1 ANDtable1.col2 = table2.col2 AND... etc ... - Jeff |
 |
|
|
dcarva
Posting Yak Master
140 Posts |
Posted - 2003-09-28 : 20:03:49
|
| Yes, that's it! I tried that earlier and it didn't compile. Tried it again and it worked. So I did something wrong.THANKS!!!!! |
 |
|
|
|
|
|