Results 1 to 6 of 6

Thread: [RESOLVED] (+) in Sql

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Sep 2007
    Posts
    122

    Resolved [RESOLVED] (+) in Sql

    Good Day;

    I've a simple question :

    What the (+) is using for ?

    select * from edge.CLIENT C, edge.SOURCE S,EDGE.AGING_OFF E
    where c.salesman_code = s.source_code (+) and
    C.cust_id = E.ldg_id and
    E.ldg_type = C.supp_yn and
    E.CREATION_DATE BETWEEN '1-MAY-2011' AND '2-MAY-2011'

    Thank you

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: (+) in Sql

    (+) is not standard SQL

    If memory serves it is specific to Oracle, and means a Left Outer join or Right Outer join (depending on exactly where it is).

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: (+) in Sql

    Quote Originally Posted by si_the_geek View Post
    (+) is not standard SQL
    It is not standard T-SQL, but it is standard PL/SQL
    Quote Originally Posted by si_the_geek
    If memory serves it is specific to Oracle, and means a Left Outer join or Right Outer join (depending on exactly where it is).
    You are correct, and it confused the ever lovin' bejesus out of me when I did my very first project with Oracle as the back end.

    It is backwards to what you think you would do for LEFT and RIGHT outer joins.

    It is difficult to explain...

    When you want to code a Left Outer Join, you put the (+) sign on the table that satisfies the "right" table join condition

    When you want to code a Right Outer Join, you put the (+) sign on the table that satisfies the "left" table join condition

    To this day, that doesn't make sense to me (althought I understand it (I think)).

    Having said that I didn't use it and explicity said "RIGHT OUTER JOIN" or "LEFT OUTER JOIN" in my queries.

  4. #4
    PowerPoster
    Join Date
    Nov 2002
    Location
    Manila
    Posts
    7,629

    Re: (+) in Sql

    I'm just guessing but it's probable related to tree view control: (+) to expand, (-) to collapse

    The table column in the join with the (+) is the one that can be thought of as "expandable" into zero or multiple rows when related to one row of the other table.

    So for condition WHERE tblA.ID = tblB.FK_ID(+), it is tblB that determines the leaf nodes (or rows returned) using the tree view analogy (you would click the (+) to view the leaf nodes in a tree view control).

    I hope that makes it easier to remember for everyone; it works for me.
    Last edited by leinad31; May 25th, 2011 at 07:53 PM.

  5. #5
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: (+) in Sql

    As already pointed out in Oracle "+" stands for outer join:

    Left outer join:
    where c.salesman_code = s.source_code (+)

    Right outer join:
    where c.salesman_code (+) = s.source_code

    I personally prefer this syntax to one that's more explicit which requires more typing and imho is quite cumbersome.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Sep 2007
    Posts
    122

    Re: (+) in Sql

    Thanx everyone, now it is clear.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width