Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does a (+) sign mean in an Oracle SQL WHERE clause? [duplicate]

Tags:

sql

oracle

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

Consider the simplified SQL query below, in an Oracle database environment (although I'm not sure that it's Oracle-specific):

SELECT     t0.foo, t1.bar FROM    FIRST_TABLE t0, SECOND_TABLE t1 WHERE    t0.ID (+) = t1.ID; 

What is that (+) notation for in the WHERE clause? I'm sorry if this is an ignorant newbie question, but it's been extremely difficult to search for on Google or StackOverflow... because even when using quote marks, search engines see a '+' sign and seem to want to treat it as some kind of a logical directive.

like image 987
Steve Perkins Avatar asked Nov 18 '10 16:11

Steve Perkins


People also ask

What does a (+) sign mean in an Oracle SQL where clause?

The plus sign is Oracle syntax for an outer join. There isn't a minus operator for joins. An outer join means return all rows from one table. Also return the rows from the outer joined where there's a match on the join key.

What does Column_name (+) mean in SQL?

It means that it will include all rows from t1, and use NULLS in the t0 columns if there is no corresponding row in t0. In standard SQL one would write: SELECT t0.

What is the use of (+) in SQL?

The thing is the (+) operator is placed directly in the conditional statement and on the side of the optional table (the one which is allowed to contain empty or null values within the conditional).

What does the sign mean in SQL?

This function in SQL Server is used to return the sign of the specified number. It returns 1 if the number is positive, -1 if the number is negative and 0 for zero number.


1 Answers

This is an Oracle-specific notation for an outer join. It means that it will include all rows from t1, and use NULLS in the t0 columns if there is no corresponding row in t0.

In standard SQL one would write:

SELECT t0.foo, t1.bar   FROM FIRST_TABLE t0  RIGHT OUTER JOIN SECOND_TABLE t1; 

Oracle recommends not to use those joins anymore if your version supports ANSI joins (LEFT/RIGHT JOIN) :

Oracle recommends that you use the FROM clause OUTER JOIN syntax rather than the Oracle join operator. Outer join queries that use the Oracle join operator (+) are subject to the following rules and restrictions […]

like image 94
Benoit Avatar answered Oct 13 '22 08:10

Benoit