Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8518873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T06:05:55+00:00 2026-06-11T06:05:55+00:00

User: id | name 1 | one 2 | two 3 | three 4

  • 0
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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T06:05:56+00:00Added an answer on June 11, 2026 at 6:05 am

    In SQL, this type of query needs what is known as an EXCEPTION JOIN. Some RDBMSs actually implement this as a separate type (such as DB2), while others need to use a workaround. In your case, it amounts to (in SQL):

    SELECT User.* 
    FROM User
    LEFT JOIN UserHouse
    ON UserHouse.id_user = User.id
    WHERE UserHouse.id_user IS NULL
    

    Which will yield the expected ‘not in a house’ records.

    There are similar examples in a number of places on this site.

    I’ve never used Doctrine, so I can’t help you there. But my best guess would be something like:

    addWhere('uh IS NULL')
    

    or

    addWhere('uh.id_user IS NULL')
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

ColumnOne ColumnTwo ColumnThree Columnfour Columnfive ColumnSix one two three four 0 'Button Here' As
I have in database: User: id | name 1 | one 2 | two
I have two models: User (email:string) Profile (name:string) class User < ActiveRecord::Base has_one :profile
I have multiple datepickers in one page. I user class name to set the
I have three tables, table one (tableA) containing users data like name and email,
Currently I have three models in Django that create a circular reference: A User
The fact that Delicious has two sets of API authentications one with username and
Hi every one I have these classe @Entity @Table(name = login, uniqueConstraints={@UniqueConstraint(columnNames={username_fk})}) public class
I have 2 tables - one storing user information (id, username, password) and the
My table is having four fields in which two fields are unique. They are

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.