This question already has answers here:
Oracle "(+)" Operator
(4 answers)
Closed 9 years ago.
The query is as follows
select tbl1.x, tbl2.y
from
tbl1, tbl2
where tbl1.some_column (+) = tbl2.some_column
AND tbl1.some_column2 (+) = 'Y'
What confuses me is this part
AND tbl1.some_column2 (+) = 'Y'
What does it mean?? If I remove the (+) the query returns completely different number of rows. I do understand the application of (+) when there are columns names on the both sides of the =, but what does (+) do when there is a string on the one side of the = ?
It's legacy syntax that Oracle had before they had LEFT OUTER JOIN (or, in this case, probably RIGHT OUTER JOIN).
No need to use it anymore in modern Oracle (at least from 9i, maybe even 8i).
Now you can use the standard SQL join syntax:
SELECT tbl1.x, tbl2.y
FROM tbl1 RIGHT OUTER JOIN tbl2
ON ( tbl1.some_column = tbl2.some_column AND tbl1.some_column2 = 'Y')
Related
This question already has answers here:
Oracle: What does `(+)` do in a WHERE clause?
(4 answers)
Closed 5 years ago.
Recently I observed the following syntax:
AND TRUNC (SYSDATE) + 1 BETWEEN a(+) AND b(+)
I know that the (+) sign is used to address left or right join in conditions like:
and a = b(+)
... but I have no idea what it means in the BETWEEN function.
Can someone explain, please, or better give an example using BETWEEN function?
Thank you,
The Oracle docs says:
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, which do not apply to the FROM clause OUTER JOIN syntax:
This question already has answers here:
Oracle "(+)" Operator
(4 answers)
Closed 6 years ago.
Suppose there is one condition,
(+) =
i know (+) used in join of column but what does it mean in this condition
The Oracle (+)= syntax is the equivalent for OUTER JOINS.
a.column (+)= b.column
means "retrieve the record from b even if there is no match with a" (RIGH OUTER JOIN)
a.column = b.column (+)
means "retrieve the record from a even if there is no match with b" (LEFT OUTER JOIN)
This question already has answers here:
Oracle "(+)" Operator
(4 answers)
How to find LEFT OUTER JOIN or RIGHT OUTER JOIN with ORACLE JOIN (+)
(2 answers)
Closed 7 years ago.
I'm quite new to oracle sql and just ran into a query that looks something like this
SELECT some_field
FROM some_table
WHERE some_other_field=some_value(+);
I simplified and annonimized the code, but im curious whats the (+) at the end. I don't remember seeing that in mssql world ever.
It's Oracle old outer join syntax:
To write a query that performs an outer join of tables A and B and
returns all rows from A (a left outer join), use the LEFT [OUTER] JOIN
syntax in the FROM clause, or apply the outer join operator (+) to all
columns of B in the join condition in the WHERE clause. For all rows
in A that have no matching rows in B, Oracle Database returns null for
any select list expressions containing columns of B.
http://docs.oracle.com/cd/B19306_01/server.102/b14200/queries006.htm
This question already has answers here:
What does (+) do in Oracle SQL?
(4 answers)
Closed 9 years ago.
I just stumbled across a SQL+-Query which uses (+). I've never worked with SQL+ before and I've never seen something like this. I tried to ask Google about it, but I couldn't find anything useful since Google obviously filters the "(+)" and just ignores it...
Example:
[...]
where [...]
AND 16791688 = T7mm.child_fielddef_id (+)
AND T7mm.parent_dbid = T7.dbid (+)
AND T1.dbid <> 0 [...]
it is an Oracle specific shortcut for OUTER JOIN
It makes the join an outer join rather than an inner join:
SELECT
A.*,
B.*
FROM
A,
B
WHERE
A.ID = B.ID(+)
is equivalent to:
SELECT
A.*,
B.*
FROM
A
LEFT JOIN B ON A.ID = B.ID
The (+) notation is the old Oracle syntax for SQL queries. Now it is generally viewed as best practice to use the ANSI standard with the LEFT JOIN keywords instead
This question already has answers here:
Closed 12 years ago.
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.
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 […]