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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:36:13+00:00 2026-05-11T20:36:13+00:00

Is it true that no matter which type of join you use, if your

  • 0

Is it true that no matter which type of join you use, if your WHERE clause checks one table’s pk = other table’s fk, it becomes same as an inner join as far as the result set is conncerned? In other words, if your sql query has some stuff like:

“Select … from A Left join B On (…) E, F Full Outer Join G on (A.pk = G.fk) … WHERE A.pk = G.fk and A.pk = B.fk and etc…”

In the above query, A is left-joined to B, whereas G is outer-joined to A on its fk. But as the where clause has the two checks, so the whole query reduces to something like:

“Select … from A INNER JOIN B On (…) E, F INNER Join G on (A.pk = G.fk) … WHERE etc …”
?

The reason for asking this query is that I have many cartesian-type joins along with where clauses that are on one table’s pk = other table’s fk, that are slowing the query down. I was thinking of replacing the cartesian products with either Left Joins combined with keeping all the where clauses, or all Inner Joins.

  • 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-11T20:36:13+00:00Added an answer on May 11, 2026 at 8:36 pm

    Yes if you refernce the right side of a left outer join in a where clause with anything except “where myfield is null”, you have created an inner join. This is because it filters out anything that that doesn’t meet that condition including all the records that don’t have a match to the intial table. Same with the other non-inner joins. To get around it you put the condition in the join. Example (this turns it into an inner join):

    Select field1, field2 from mytable mt
    left join mytable2 mt2 on mt.id = m2.id
    where mt1.field1 = 'hello' and mt2.field2 = 'test'
    

    Rewritten to preserve the left join:

    Select field1, field2 from mytable mt
    left join mytable2 mt2 on mt.id = m2.id and mt2.field2 = 'test'
    where mt1.field1 = 'hello' 
    

    I also want to comment on something you said in a comment but figured my response would be too long for another comment.

    “Select … From A Inner Join B on (A.id = B.a_id),C,D, F where A.id=F.id”
    to: “Select … From A Inner Join B on (A.id = B.a_id),C,D INNER JOIN F on A.id = F.a_id”

    You do not want to combine syntaxes like this; this becomes very hard to maintain. In fact I recommend never using the old style comma syntax as it is subject to accidental cross joins. So in your example I would write to get the result set you currently get (at least someone maintaining will know you indended a cross join instead of did it by accident):

    Select ... From A 
    INNER JOIN B on A.id = B.a_id 
    INNER JOIN F on A.id = F.a_id
    CROSS JOIN C
    CROSS JOIN D
    

    Altenatively if the cross join is accidental, the code would change to:

    Select ... From A 
    INNER JOIN B on A.id = B.a_id
    INNER JOIN F on A.id = F.a_id
    INNER JOIN C on (fill in the join fields)
    INNER JOIN D on (fill in the join fields)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it true that you cannot use COM Interop to expose COM properties? Everything
The big problem lies in the fact that the code, no matter which number
I have a form that has a bunch of CCK fields, one of which
I am attempting to use reflection to determine which Properties of a Type have
Is it true that this does not necessarily mean the stream has been disposed
Question Is it true that C-style strings operations, on average, execute 5 times slower
is it true that Rails depend on cookies? It seems that flash is a
Is it true that a service written in C# is unable to give visual
Is it true that any REST based API to upload videos will always require
Is this true that Update SQL Query is slow because of Clustered index??????

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.