So, I am not sure what the best way to do a join for these tables was. I want to use a JOIN because I believe it is faster than bring all three of the tables in on FROM. So, if i have three tables…
Table1
--id
--data
Table2
--id
--data
Table1_Table2
--table1_id
--table2_id
How can I do a join for this data using the join table?
Mentioning all tables in the
FROMclause is also a join, implicit one. It is not recommended to use it as it might lead to a Cartesian product of the tables involved in case you’ll forget to add predicates in theWHEREclause.Have a look on the Wikipedia JOIN article and also at this very nice blogpost about joins by Jeff Atwood.
I think that you’re interested in the
INNER JOINbetween the tables, although other variants exists. Try this:I skipped Table1_Table2 columns from the select list, as there’s nothing special there.