User:
id | name
1 | one
2 | two
3 | three
4 | four
5 | five
House:
id | name
1 | London
2 | Barcelona
UserHouse:
id_user | id_house
1 | 1
2 | 2
4 | 1
$q = Doctrine_Query::create()
->from('User u')
// many selectors here
->leftJoin('u.UserHouse uh')
->addWhere('????????');
$users = $q->execute();
I would like get all user without House (that is - not in table UserHouse) - this should return me user 3 and 5.
I know, i can use:
->from('UserHouse uh')
and next relation to User but i must have and use:
->from('User u')
because i use this query with many selectors - can't edit this. I must started with ->from('User u')
So what i must fill in ->addWhere('????????') that this return me users without house?
If not with Doctrine, how can i get this with simply SQL?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…