I have to join two tables. But in one table primary key is not there,composite primary key is there,means three columns put together uniquely define a row of that table. I have those three columns in the other table too.rest nothing is common. Is there any way to join these two tables.please explain with the help of example
Asked
Active
Viewed 6.4k times
47
-
2You don't need a key to join tables. It will just be less efficient. – Barmar Dec 22 '14 at 17:28
-
2Your question isn't clear. What problem are you having with joining the tables? – Barmar Dec 22 '14 at 17:29
1 Answers
79
You can use AND in the expression for the ON criteria and demand the fields are all equal there.
SELECT *
FROM Table1
INNER JOIN Table2
ON Table1.Key1 = Table2.Key1 AND Table1.Key2 = Table2.Key2 AND Table1.Key3 = Table2.Key3

Eterm
- 1,698
- 12
- 23