Left Table vs Right Table

Gavx

Registered User.
Local time
Today, 14:11
Joined
Mar 8, 2014
Messages
155
Can someone please explain the significance of right versus left join of a 2 tables.

When is it right...or left for that matter.

Thanks
 
I understand the joint type between the two tables but I still do not get the significance of being on the right...or the left.

Right outer join for example only has meaning if we know what table is on the right.

I think the joint type explanation is more meaningful. That is, for example, all the records in table a and only the records in table b that occur in table a.

...or is there something more with respect to right and left, that I am not aware of.
 
No. Its really just syntax they achieve the same thing (all from one table, just matching from other table).
 
table1 left join table2 on... (returns all records in table1)

is the same as

table2 right join table1 on... (returns all records in table1)

so visually in the code in the first example, table1 is on the left of the join and to the right for the second example

In your query builder or relationships window, when you create a relationship by dragging from one table field to another in another table, the code will be created based on the first table selected to the left of the join and the table you are joining to to the right.
 
In nongenerated SQL I usually advice people to stick to only LEFT joins, we europeans simple work best left to right and top to bottom

Mixing Lefts and Rights (and even Inners) can lead to impossible queries or unwanted results if you are not carefull.

I.e.
Code:
Select
From   Table1
Left join table2 on Table1.Key = Table2.Key
Inner join Table3 on Table2.key2 = Table3.key2

Wont work as expected unless you start adding brackets and/or subselects.
 

Users who are viewing this thread

Back
Top Bottom