Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does (+) do in Oracle SQL?

Tags:

sql

join

oracle

I'm using Oracle SQL Developer to query an Oracle DB (not sure which version it is) and I'm going to use the SQL I make for a Crystal report. Many of the reports the previous developers have written don't use JOIN keywords to make the joins (and I'm not too familiar with JOIN keywords as a result).

Many of the joins they make are made in the WHERE statement. I'll notice something like this.

Select * From TableA, TableB WHERE TableA.PrimaryKey(+) = TableB.ForeignKey

My question is concerning the (+). What purpose does it serve and how do I use it in my code?

like image 393
mandroid Avatar asked Sep 03 '09 23:09

mandroid


3 Answers

It is not recommended. See this previous answer

Difference between Oracle's plus (+) notation and ansi JOIN notation?

like image 125
BobbyShaftoe Avatar answered Oct 14 '22 19:10

BobbyShaftoe


That represents a “right outer join” (right because the = is on the right side of the +).

SELECT *
FROM TableA, TableB
WHERE TableA.PrimaryKey(+) = TableB.ForeignKey

is equivalent to

SELECT *
FROM TableA
RIGHT OUTER JOIN TableB
  ON (TableA.PrimaryKey = TableB.ForeignKey)
like image 45
Michael Todd Avatar answered Oct 14 '22 19:10

Michael Todd


right outer join

like image 30
softveda Avatar answered Oct 14 '22 20:10

softveda