DEV Community

[Comment from a deleted post]
Collapse
 
aarone4 profile image
Aaron Reese

In mssql (not sure of other dialects) you can drop the inner for join, left and right. You only need outer on the full outer join. In 25 years of working in SQL I have never come across a legitimate use for Right Join. RJ means you don't understand your data.

Collapse
 
dmfay profile image
Dian Fay

I've used right joins a handful of times, most recently joining a table of weather stations to a CTE representing intervals during which stations were or weren't deployed (the latter being of primary interest). Left joins are certainly much more intuitive in almost all cases, but I suspect that has more to do with English-readers being used to processing left to right than anything else.

 
aarone4 profile image
Aaron Reese • Edited

In which case it should have been

SELECT 
        CTE.column
        ,STATION.data
FROM
        CTE
    LEFT JOIN STATION ON STATION.CTE_ID = CTE.ID