SQL Multiply Equals (*=) in a WHERE clause [duplicate] - sql

This question already has answers here:
SQL Server *= Operator?
(6 answers)
Closed 8 years ago.
I just saw the weirdest thing ever in some very old SQL code we have.
There is a multiply equals operator in a where clause. Does it have a special meaning? It selects the appropriate columns, but o.name is NULL.
I am sure it is a typo, but I just want to confirm.
select c.name,
c.status,
o.name
from syscolumns c,
sysobjects o
where c.id = object_id('dbo.MyTable')
and c.cdefault *= o.id
order by colid asc

This question was already answered here: SQL Server *= Operator?
Beyond being the oldschool way, as fancyPants mentioned, it also may not always work consistently. You should revise your SQL statement to include the JOINS in the FROM clause.
To answer your question: *= is a LEFT OUTER JOIN, while =* is a RIGHT OUTER JOIN

As mentioned, this is a LEFT OUTER JOIN. Similarly, =* is a RIGHT OUTER JOIN
That said, it shouldn't be used anymore, and you should use the full syntax.

*= (LEFT OUTER JOIN)
=* (RIGHT OUTER JOIN)

Related

Why do we need an optional keyword OUTER in SQL? [duplicate]

This question already has answers here:
LEFT JOIN vs. LEFT OUTER JOIN in SQL Server
(12 answers)
Closed 5 years ago.
LEFT JOIN and LEFT OUTER JOIN works exactly the same way.
Which means the keyword OUTER has no effect or it is optional.
Why do we include a keyword which has no effect in execution?
It is optional, I always assumed that it was originally there as its more descriptive.
However it doesn't actually mean anything as a join is either inner, left, right or full - so the outer key word can be inferred to be relevant for all but inner joins.

what the mening of (+) in BETWEEN function [duplicate]

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:

what is (+) syntax in SQL query [duplicate]

This question already has answers here:
Difference between Oracle's plus (+) notation and ansi JOIN notation?
(8 answers)
Closed 9 years ago.
I want to know what the (+) in the below query signify,
select ..
from ..., Fat fat
where prop = fat.prop (+)
Thanks
It is the obsolete outer join symbol.
In Oracle, (+) denotes the "optional" table in the JOIN.
You may check out this for Left and Right Outer Joins.
On a side note:-(Although its obsolete)
The placement of the (+) determines RIGHT or LEFT. If the (+) is on the right, it's a LEFT JOIN and if (+) is on the left, it's a RIGHT JOIN.
For Oracle specifically, indicates a Left Outer Join. Older notation.
Out of date format of outer join. Means only matching rows on the (+) sign side and all rows on the other side. You should use the LEFT/RIGHT OUTER JOIN notation instead.

What does (+) mean in SQLPlus? [duplicate]

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

(+) symbol in SQL Query

Just i have came across a SQL query in one of the stored procedure like below:
SELECT
*
FROM
account a,
performance p,
customer c,
override o
WHERE
a.account_id = p.account_id (+)
AND a.account_id = c.account_id (+)
AND o.override_type(+) = 'O'
Can you please explain what is the (+) symbol's play here? and the difference of using Left side and right side.
Thanks in advance.
It is the old syntax for OUTER JOIN in Oracle (I don't know whether there are other RDBMS that uses the same old syntax or not).
Better off: Use the explicit ANSI-92 OUTER JOIN syntax using LEFT OUTER JOIN or RIGHT OUTER JOIN instead of the + symbol.
(+) is an legacy outer join syntax in oracle (8 and before). It is very restrictive and handles many cases just wrong. Don't use it anymore. Oracle supports ansi joins (eg. left outer join) since version 9.