1
0
mirror of synced 2024-12-15 07:36:03 +03:00
doctrine2/manual/codes/DQL (Doctrine Query Language) - Conditional expressions - Subqueries.php

20 lines
634 B
PHP
Raw Normal View History

2006-10-20 23:31:37 +04:00
<?php
// finding all users which don't belong to any group 1
$query = "FROM User WHERE User.id NOT IN
(SELECT u.id FROM User u
INNER JOIN u.Group g WHERE g.id = ?";
$users = $conn->query($query, array(1));
// finding all users which don't belong to any groups
// Notice:
// the usage of INNER JOIN
// the usage of empty brackets preceding the Group component
$query = "FROM User WHERE User.id NOT IN
(SELECT u.id FROM User u
INNER JOIN u.Group g)";
$users = $conn->query($query);
?>