Who uses RIGHT JOIN?

  • Just wondering, does anyone here use the RIGHT JOIN operator?

    Can't you do everything a RIGHT JOIN can do using a LEFT JOIN (just flip the tables around)?

    Of course, if you are a RIGHT JOIN activist, then the subject of this thread should read "Who uses a LEFT JOIN"?)

    Thanks in advance,

    Billy

  • bp,

    I tend to avoid RIGHT OUTER JOIN when I can. I think if I find it's needed I'm usually trying to make a query do too much at once.

    I have used RIGHT OUTER JOINs in ad hoc analysis, mostly to keep things readable and my sanity intact. It comes in handy when I have a central dataset represented in a big, parenthetical INNER JOIN that I need to knock against more than one other dataset (that may also use parenthetical syntax). It keeps the ON clauses tidier, IMO.

    My $.02,

    --SJT

  • I tend to allmost always use left join.  It highlights the table that is going to show all rows.

    I think that I tend to use Right joins when I am trying to repair a query. I have found that a large number of ASP developers and power users use inner joins exclusively.  Then they wonder why no records are returned.  Rather than reordering all of the tables, I will frequently leave the order of tables alone and will use right joins when I need to and left joins when I need to.

    Rus

    Russel Loski, MCSE Business Intelligence, Data Platform

  • RIGHT JOIN is something I seldom need to use. Every so often though it seems a logical choice, mostly for ad hoc queries (as mentioned previously by S.J. Terril)...though, I actually have one production stored procedure that employs a RIGHT JOIN internally to return a specific data set.

    I think what causes those of us who avoid RIGHT JOINs to avoid them is simply a logical preference, and I suspect there are people who have the reverse view and avoid LEFT JOINs.

    Interesting question overall, though. It kind of raises the whole concept of preferential constructs in any language, and reminds how creative the art of coding is.

  • I used to work with DB2 years (and years :wow ago and at that time DB2 internally handled LEFT JOINS more efficiently than RIGHT JOINS.  As a result LEFT JOINS were more used in examples and in classes and I became more used to using them.  I don't know that there is any difference anymore and I don't think that T-SQL has and internal preference but I know that out of habit I have a preference for LEFT JOINS.

    Francis

  • I think it is typical for left-to-right readers to use LEFT JOIN.  I almost always use LEFT when constructing a query from scratch.  I have noticed that the Query Builder in Enterprise Manager tends to use RIGHT JOIN frequently, especially when several tables are involved.  It may be the way it parses and constructs the query from the graphical representation.  I find the query builder saves a lot of time, especially when working with OUTER JOINS, so I do have some queries with RIGHT JOIN in my work.

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply