Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What type of join is '....where A.ID = B.ID (+)'

I've come across such code which I need to re-write using ANSI Standard and I want to make sure I'm keeping the joins correct. Also, what convention is this?

What is the syntax for the other types of joins using this convention?

Using this convention will the (+) always be on the right hand side of the expression?

Where can I learn more about this?

like image 244
zundarz Avatar asked Nov 30 '11 16:11

zundarz


2 Answers

In Oracle syntax, this signifies a LEFT OUTER JOIN, the right side being optional (nullable). If the + was on the left side by A.ID, it would have been a RIGHT OUTER JOIN. This syntax is (I believe) deprecated by ISO SQL 99, but remains in Oracle.

It is the equivalent of this preferred syntax:

SELECT
 A.ID,
 B.somecol
FROM A LEFT OUTER JOIN B ON A.ID = B.ID
like image 125
Michael Berkowski Avatar answered Sep 30 '22 13:09

Michael Berkowski


This looks to be a basic left outer join using alternate syntax. Here's the Joins page on Wikipedia where you can see it.

Basically, it is a way to perform a conditional join and the (+) seems to be an alternate syntax. Hope this helps.

like image 37
DevinBM Avatar answered Sep 30 '22 14:09

DevinBM