I have a table of users, plus a related table called UserWorkplaces, where one user could have any number of related rows on the UserWorkplaces table.
I'm trying to build a query to find all of the users with only one related row in UserWorkplaces. What kind of query should I use to get this?
Here's what I've tried so far, but it gave me the count of everyone's workplaces and only a single user:
$query = Doctrine_Query::create()
->from('Users', 'u')
->innerJoin('u.userWorkplaces uw')
->having('COUNT(uw.id) = 1');