Home » SQL & PL/SQL » SQL & PL/SQL » SQL join
SQL join [message #641175] Tue, 11 August 2015 08:34 Go to next message
sanodani
Messages: 98
Registered: October 2014
Member
Can anyone please explain me, what actually does this (+) sign mean or .. is there any other way to make such join without using inner or outer join?

select a.id, b.name, c.address
  from a, b, c
where a.id (+) = b.id
 and  a.name (+) = b.name
 and  b.did (+) = c.did


can i write this another way?

Re: SQL join [message #641178 is a reply to message #641175] Tue, 11 August 2015 08:39 Go to previous messageGo to next message
John Watson
Messages: 8931
Registered: January 2010
Location: Global Village
Senior Member
that is an outer join, using the outdated Oracle syntax rather than the ANSI syntax that you should be using in the twentyfirst century.
Re: SQL join [message #641179 is a reply to message #641175] Tue, 11 August 2015 08:39 Go to previous messageGo to next message
BlackSwan
Messages: 26766
Registered: January 2009
Location: SoCal
Senior Member
use ANSI syntax
Re: SQL join [message #641180 is a reply to message #641175] Tue, 11 August 2015 08:44 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
sanodani wrote on Tue, 11 August 2015 14:34
is there any other way to make such join without using inner or outer join?


What other type of join did you have in mind?
Re: SQL join [message #641181 is a reply to message #641175] Tue, 11 August 2015 08:45 Go to previous messageGo to next message
Michel Cadot
Messages: 68647
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator

Quote:
can i write this another way?


LEFT/RIGHT OUTER JOIN
See Join.

Re: SQL join [message #641240 is a reply to message #641175] Wed, 12 August 2015 04:59 Go to previous message
Lalit Kumar B
Messages: 3174
Registered: May 2013
Location: World Wide on the Web
Senior Member
sanodani wrote on Tue, 11 August 2015 19:04
Can anyone please explain me, what actually does this (+) sign mean


As others have said, it is old Oracle join syntax.

One of the good reasons to use ANSI syntax over the old Oracle join syntax is that, there are nil chances of accidentally creating a cartesian product. With more number of tables, there is a chance to miss an implicit join with older Oracle join syntax, however, with ANSI syntax you cannot miss any join as you must explicitly mention them.

Difference between Oracle outer join syntax and the ANSI/ISO Syntax.

LEFT OUTER JOIN -

SELECT e.last_name,
  d.department_name
FROM employees e,
  departments d
WHERE e.department_id = d.department_id(+);

SELECT e.last_name,
  d.department_name
FROM employees e
LEFT OUTER JOIN departments d
ON (e.department_id = d.department_id);


RIGHT OUTER JOIN -

SELECT e.last_name,
  d.department_name
FROM employees e,
  departments d
WHERE e.department_id(+) = d.department_id;

SELECT e.last_name,
  d.department_name
FROM employees e
RIGHT OUTER JOIN departments d
ON (e.department_id = d.department_id);


FULL OUTER JOIN -

Before the native support of hash full outerjoin in 11gR1, Oracle would internally convert the FULL OUTER JOIN the following way -

SELECT e.last_name,
  d.department_name
FROM employees e,
  departments d
WHERE e.department_id = d.department_id(+)
UNION ALL
SELECT NULL,
  d.department_name
FROM departments d
WHERE NOT EXISTS
  (SELECT 1 FROM employees e WHERE e.department_id = d.department_id
  );

SELECT e.last_name,
  d.department_name
FROM employees e
FULL OUTER JOIN departments d
ON (e.department_id = d.department_id);


Read the documentation for more about Joins.
Previous Topic: Transpose of rows to Columns & Dynamically Adding the Columns (merged)
Next Topic: Cursor Query help
Goto Forum:
  


Current Time: Fri Apr 26 23:14:43 CDT 2024