When or why would you use a right outer join instead of left?

后端 未结 11 678
小蘑菇
小蘑菇 2020-11-27 05:47

Wikipedia states:

\"In practice, explicit right outer joins are rarely used, since they can always be replaced with left outer joins and provide no additional functi

11条回答
  •  天涯浪人
    2020-11-27 06:24

    B RIGHT JOIN A is the same as A LEFT JOIN B

    B RIGHT JOIN A reads: B ON RIGHT, THEN JOINS A. means the A is in left side of data set. just the same as A LEFT JOIN B

    There are no performance that can be gained if you'll rearrange LEFT JOINs to RIGHT.

    The only reasons I can think of why one would use RIGHT JOIN is if you are type of person that like to think from inside side out (select * from detail right join header). It's like others like little-endian, others like big-endian, others like top down design, others like bottom up design.

    The other one is if you already have a humongous query where you want to add another table, when it's a pain in the neck to rearrange the query, so just plug the table to existing query using RIGHT JOIN.

提交回复
热议问题