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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:48:15+00:00 2026-05-12T13:48:15+00:00

How can I replicate a LEFT OUTER JOIN in a WHERE clause? Essentially, I

  • 0

How can I replicate a LEFT OUTER JOIN in a WHERE clause? Essentially, I want to use a cross rather than a join in the FROM clause and then filter the second table accordingly:


    SELECT A.KEY, B.KEY
    FROM A, B
    WHERE ?????;

Note the key will not be null in either case and will be unique.

  • 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-12T13:48:16+00:00Added an answer on May 12, 2026 at 1:48 pm

    David,

    My cryptic answer is “You can’t.” Despite answers given by others, the cross join doesn’t contain the information you want in the first place. If you restrict the result set of the cross join to a subset of the cross join (which is what a WHERE clause is for), you won’t get what you want. Unless, of course, you use the vile and evil *= operator, which turns the mathematical/relational meaning of a WHERE clause on its head.

    Yaraher’s suggestion of UNION was reasonable thinking (if bad execution), and in fact, in the SQL standard, OUTER joins are defined in terms of inner joins with unions. So if you object to the word OUTER, you can do this:

    SELECT A.KEY, B.KEY
    FROM A, B
    WHERE A.KEY *= B.KEY
    UNION ALL
    SELECT A.KEY, NULL
    FROM A
    WHERE NOT EXISTS (
      SELECT * FROM B AS B2
      WHERE B2.KEY = A.KEY
    )
    

    But absent perversions of the language like *=, you can’t get more (the outer rows) by asking for less (adding a WHERE clause).

    I agree wholeheartedly with gbn, who says *= “will bite you later.” Or it will bite somebody and be your fault. It’s evil (did I say that yet?), and in fact some more complicated queries containing that operator are simply not well-defined. If the *= operator gets buried in a view somewhere, you’re in trouble.

    Using *= is irresponsible. It’s like using 18-gauge wire to wire a switch for a 20-amp circuit you happen to be using only for a half-amp motor. If there were a SQL code like there is an electrical code, *= wouldn’t meet code. (And fortunately, in some shops, like Adam’s, it doesn’t.)

    (You can’t even type in into Stackoverflow too close to Italic text without escaping it, it’s so bad.)

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

Sidebar

Ask A Question

Stats

  • Questions 215k
  • Answers 215k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Just use a raw JNDI lookup: public void setDataSourceName(String name)… May 12, 2026 at 10:55 pm
  • Editorial Team
    Editorial Team added an answer http://www.w3.org/TR/html4/present/frames.html div { padding:0;margin:0; } .container { position:relative; width:100%; height:100%;… May 12, 2026 at 10:55 pm
  • Editorial Team
    Editorial Team added an answer Your problem is that you are using floats. On the… May 12, 2026 at 10:55 pm

Related Questions

I have two tables which I want to join together using a left outer
Brief question What command can I use to make my DataSet refresh it's connection
I am using Qt to develop a cross platform application. I am trying to
I need to resize a div shown as a message in blockUI so that

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.