sqloracle-databaseoperators

Oracle: What does `(+)` do in a WHERE clause?


Found the following in an Oracle-based application that we're migrating (generalized):

SELECT
    Table1.Category1,
    Table1.Category2,
    count(*) as Total,
    count(Tab2.Stat) AS Stat
FROM Table1, Table2
WHERE (Table1.PrimaryKey = Table2.ForeignKey(+))
GROUP BY Table1.Category1, Table1.Category2

What does (+) do in a WHERE clause? I've never seen it used like that before.


Solution

  • Depending on which side of the "=" the "(+) is on, it denotes a LEFT OUTER or a RIGHT OUTER join (in this case, it's a left outer join). It's old Oracle syntax that is sometimes preferred by people who learned it first, since they like that it makes their code shorter.

    Best not to use it though, for readability's sake.