xxxxxxxxxx
They are functionally equivalent, but INNER JOIN can be a bit clearer to read, especially if the query has other join types (i.e. LEFT or RIGHT or CROSS) included in it.
xxxxxxxxxx
In SQL, a join is used to compare and combine — literally join — and
return specific rows of data from two or more tables in a database.
An inner join finds and returns matching data from tables,
while an outer join finds and returns matching data and some dissimilar
data from tables
INNER JOIN :
The inner join will keep only the information from the two joined tables
that is related.
OUTER JOIN:
There are three types of outer joins:
Left Outer Join (or Left Join)
Right Outer Join (or Right Join)
Full Outer Join (or Full Join)
xxxxxxxxxx
SELECT * FROM TableA AS a INNER JOIN TableB AS b USING (Column1);
SELECT * FROM TableA AS a INNER JOIN TableB AS b ON a.Column1 = b.Column1;
xxxxxxxxxx
ON replaces the original join condition,
WITH adds a condition to it.
Example:
[Album] ---OneToMany---> [Track]
Case One
DQL
FROM Album a LEFT JOIN a.Track t WITH t.status = 1
Will translate in SQL
FROM Album a LEFT JOIN Track t ON t.album_id = a.id AND t.status = 1
Case Two
DQL
FROM Album a LEFT JOIN a.Track t ON t.status = 1
Will translate in SQL
FROM Album a LEFT JOIN Track t ON t.status = 1