Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I prefer Q3's JOIN's condition order too:</p> <pre><code>... ON B.id = A.id -- (Q3) </code></pre> <p>As it directly reflects that the B.id is the more varying one, you can think of A.id as the constant being tested against, e.g.</p> <pre><code>B.id = 1984 </code></pre> <p>In the same vein that I don't want to see this in code...</p> <pre><code>1984 = B.id </code></pre> <p>...,like you I don't want to see this in query: </p> <pre><code>A.id = B.id </code></pre> <p>However, like most things in life, there are people who like little-endian, and there are those who like big-endian. Whatever mental model it may serve them on the preference they have chosen, they should be at least able to explain to you the rationale why they wanted <code>A.id = B.id</code></p> <p>I think, I have to switch my preference though, my(and your) preferred condition order doesn't work in some ORM, Linq in particular. I have yet to grasp why they impose that the condition should be in Q1's order:</p> <pre><code>from x in A join y in B on x.id equals y.id </code></pre> <p>And reversing the condition (same as Q3, though in SQL query it is not an error) order results to syntax error, this won't be accepted by Linq:</p> <pre><code>from x in A join y in B on y.id equals x.id </code></pre> <p>Now, I have to find the rationale why Microsoft Linq designers preferred the Q1 condition's order. And try to appreciate it if it makes sense, and just accept even it doesn't (yet) makes sense.</p> <hr/> <p>Regarding:</p> <blockquote> <p>Does the order of expressions or predicates make any difference in the join condition for outer joins in standard SQL?</p> </blockquote> <p>Results-wise, <strong>NO</strong>. Performance-wise, I have yet to see a query where the join's condition order makes the query faster. Even in forums I haven't seen anyone endorses reversing the condition to make the query faster.</p> <p>If they can't explain to you the rationale or the mental model of their preferred condition's order serves, perhaps they are just doing <a href="http://en.wikipedia.org/wiki/Cargo_cult_programming" rel="nofollow">Cargo Cult Programming</a> or worse yet, <a href="http://en.wikipedia.org/wiki/Parkinson%27s_Law_of_Triviality" rel="nofollow">Bikeshedding</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload