Does the order of expressions or predicates make any difference in the join condition for outer joins in standard SQL? -


so i'm having bit of frustrating day. fired contract had been working past few weeks because did not "mesh team." 2 examples cited:

1) yesterday asked delete data sql server database except baseline system data. requestor (not boss) had 8 scripts had used task few months ago. apparently no 1 has ever thought script out data model or system data.

this person had established pattern of over-complicating things, trying understand reasons task , end goal. struggled understand why got sorts of vague errors required these scripts "remove , re-add constraints".

i quite willing necessary , talked several minutes it. obvious reasons thought seeking understand why thing. decided faster herself rather spend time explaining me , went other work without thinking more it.

somehow interpreted negatively.

2) several weeks ago during first week asked work on merging data system. given 600+ line script of sql snippets appeared important along oral tirade of complaints poor data , original programmers. naturally took bit of time wade through closely after few days final result emerged simple merge in 25 lines.

i've been writing sql more ten years , consider myself have expertise in area. coworkers getting little impatient peeled away layers of unnecessary complexity , stayed late finish task promised.

i wasn't sure how readily accept solution of problem appeared 1 short command , wondered if missing prove embarrassing. unfortunately of probing questions had been repeatedly met kind of dismissive non-answers poor teachers give overly-curious elementary student. sent query along in email , went home.

the next morning told (same person #1) wrong stuff couldn't expected know new guy. explained had restrain herself rewriting all. 1 of points minor data had intended ask myself. other purely sql.

(the question starts here.)

take typical left outer join scenario. know order of tables quite significant, e.g., q1 , q2 not equivalent:

select a.x, b.y left outer join b on a.id = b.id -- (q1) select a.x, b.y b left outer join on b.id = a.id -- (q2) 

when think conceptually multiple joins seems natural me imagine picking new table object of interest , describing how rows related what's come before. keeping terms in parallel doesn't have advantage me , own habit write join condition way:

select a.x, b.y left outer join b on b.id = a.id -- (q3) 

so find myself being tutored how order of tables matters in outer join. had thought test of intelligence has been done during job interview. confusion turned stupor realized focusing on equality comparison. q3 wrong , q1 version needed instead.

i diplomatically insisted did not make difference @ , prove case if wanted. tried clarify reasoning kind of person doesn't listen closely questions no matter how phrased or how many technical words use suggest tiny level of competence, decided couldn't convince i'm not idiot. , agreed change script because wasn't worth arguing about.

i suppose not swallowing pride demonstrated not "coachable."


as style alone, conform standard employer prefers though sql sloppy in other ways. recognize old-style outer join syntax matter. beyond i've never heard make case. please answer question , redeem reputation.

does order of expressions or predicates make difference in join condition outer joins in standard sql?

no, makes no difference.

personally prefer style show in q3, of workmates prefer style in q1. don't know ever consider either of them wrong.

the query optimiser turns query inside out different, predicate doesn't exist plain comparison more when it's done it. it's lookup in index or table, , can done in 1 direction, how predicate written makes no difference.

i checked (in sql server 2005) execution plan of 2 queries predicate operands in different order, , expected identical.


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -