I have a table table_One
which has Multiple columns(Column1, Column2, Column3, Column4.....)
both references (Contains PK values for Table_two
) to another table Table_Two
. Is there any efficient way getting joining these two tables rather than joining Table_one back to table_Two Multiple Times.br/>
The Structure of the Two tables and the Desired Result Set is as follows. Table_One
Basically, you join to table 2 twice. When you do this, you MUST alias at least one of them so that SQL doesn't get confused. As a matter of practice, it's usually best to alias both of them so that when you read this code again in 6 months, it will be easier to understand.
Have you tried aliasing your table2 table and joining it twice to Table_One like below?
Following solution (SQLFiddle) reads the rows from the second table just one time:
Results: