yes you are correct that in the scenario you described, you can just simply swap table1 and 2 in your statement and you can get away with just using the right or the left. however, in the bigger picture, you have to consider that you will first set up your database design, relationships and then data will be populated. You may be flexible in what type of data gets entered, allowing null values and you may need to create reports that include these null values so the left and right joins would be necessary where you dont have records that match. You may want to include all of the rows in table1 even if there isnt a match in table2 and vice versa. You arent going to be modifying these queries after the program is developed.
If its just running manual queries in the DB interface, then yes you can get comfortable with a left or right join and you control how to include the table names in your query.
JorgeM
Senior Poster
3,996 posts since Dec 2011
Reputation Points: 294
Solved Threads: 543
Skill Endorsements: 115
Question Answered as of 3 Months Ago by
JorgeM
and
code739 Look at it this way:
select a.column1, b.column2, c.column3
from tablea a
left join tableb b
on a.id = b.a_id
right join tablec c
on a.id = c.a_id
and b.id = c.b_id
Keep adding tables and changing directions. If we only had left or right it wouldn't be possible.
adam_k
Veteran Poster
1,057 posts since Jun 2011
Reputation Points: 274
Solved Threads: 205
Skill Endorsements: 11