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 1047995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:23:17+00:00 2026-05-16T16:23:17+00:00

I have a join on two tables defined as a left outer join so

  • 0

I have a join on two tables defined as a left outer join so that all records are returned from the left hand table even if they don’t have a record in the right hand table. However I also need to include a where clause on a field from the right-hand table, but…. I still want a row from the left-hand table to be returned for each record in the left-hand table even if the condition in the where clause isn’t met. Is there a way of doing this?

  • 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-05-16T16:23:18+00:00Added an answer on May 16, 2026 at 4:23 pm

    Yes, put the condition (called a predicate) in the join conditions

       Select [stuff]
       From TableA a
           Left Join TableB b
               On b.Pk = a.Pk
                   -- [Put your condition here, like this]
                   And b.Column = somevalue
    

    The reason this works is because the query processor applies conditions in a where clause after all joins are completed, and the final result set has been constructed. So, at that point, a column from the a table on the outer side of a join that has null in a a column you have established a predicate on will be excluded.

    Predicates in a join clause are applied before the two result sets are "joined". At this point all the rows on both sides of the join are still there, so the predicate is effective.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables which I want to join together using a left outer
I have used a join query for retrieving value from two tables one is
I have two tables that I want to join together. Table1 Year, ID, Theme,
I have two tables (Table A, Table B) joined with a join table (TableAB)
In a MySQL database I have two tables linked in a join. One table
I have been trying to join two tables (USERS AND USERS_ROLES) based on their
Is is possible to programatically join two tables using Django's ORM? I have two
I have two tables in my database table1, table2. I have a join query
I have two tables user and log. I would like to join the user
I have two tables, tbl_foo and tbl_bar , and I want to join these

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.