Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between JOIN ON and JOIN WITH in Doctrine2?

What is the difference between JOIN ON and JOIN WITH in Doctrine2?

I couldn't find any relevant info in the manual.

like image 829
Trent Avatar asked Oct 30 '12 11:10

Trent


1 Answers

ON replaces the original join condition,
WITH adds a condition to it.


Example:

[Album] ---OneToMany---> [Track]
  1. 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
    
  2. 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
    
like image 147
theredled Avatar answered Nov 06 '22 09:11

theredled