Search code examples
sqljoin

Which table exactly is the "left" table and "right" table in a JOIN statement (SQL)?


What makes a given table the left table?

Is it that the table is indicated in the "FROM" part of the query?

Or, is it the left table because it is on the left hand side of the = operator?

Are the following equivalent?

SELECT *
FROM left_table
LEFT JOIN right_table ON left_table.right_id = right_table.id

and

SELECT *
FROM left_table
LEFT JOIN right_table on right_table.left_id = left_table.id

Solution

  • The Left table is the first table in the select. Yes, your two examples are equivalent.