/ Published in: SQL
I had a situation recently where I needed to join the same table on different columns. Most web sites don't give an example of this, so I thought it a good idea to post here. The example below only shows joining twice, but you can join as many times as necessary.
Expand |
Embed | Plain Text
SELECT column1, table2.COLUMN AS column2, table3.COLUMN AS column3 FROM table1 JOIN otherTable AS table2 ON table1.FK1 = table2.PK JOIN otherTable AS table3 ON table1.FK2 = table3.PK WHERE table1.PK = ?
You need to login to post a comment.
