SQL outer join syntax error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Powell

    SQL outer join syntax error

    I'm not kidding, the only reason yesterday you didn't hear from me was
    because I wasn't coding, but today I am doing something quick, and yes, as
    always it failed.. right at the SQL statement:


    $sql = 'SELECT v.nnet_produkt_ varegruppe_navn , ' .
    ' f.nnet_produkt_ farge_navn, ' .
    ' s.nnet_produkt_ storrelse_navn, ' .
    ' k.nnet_produkt_ kvalitet_navn, ' .
    ' p.* ' .
    'FROM nnet_produkt p, nnet_produkt_va regruppe v, ' .
    ' nnet_produkt_kv alitet k, nnet_produkt_st orrelse s ' .
    'WHERE p.nnet_produkt_ varegruppe_code =
    v.nnet_produkt_ varegruppe_code ' .
    ' AND p.nnet_produkt_ farge_code = f.nnet_produkt_ farge_code ' .
    ' AND p.nnet_produkt_ storrelse_id (+) =
    s.nnet_produkt_ storrelse_id ' .
    ' AND p.nnet_produkt_ kvalitet_id (+) =
    k.nnet_produkt_ kvalitet_id';

    I am getting "invalid SQL near (+). That is totally VALID SQL syntax for an
    outer join! If mySQL doesn't allow for that, what am I supposed to do in
    lieu of the fact that I have to logically join two tables together or if the
    one is null (the case for an outer join)?

    Phil


  • Kurt Milligan

    #2
    Re: SQL outer join syntax error

    I don't believe the (+) syntax is valid in MySQL. I've used it many
    times in Oracle, but in MySQL you have to spell out "LEFT JOIN" etc.

    Take a look at http://www.mysql.com/doc/en/JOIN.html for examples.

    HTH
    -Kurt


    Phil Powell wrote:[color=blue]
    > I'm not kidding, the only reason yesterday you didn't hear from me was
    > because I wasn't coding, but today I am doing something quick, and yes, as
    > always it failed.. right at the SQL statement:
    >
    >
    > $sql = 'SELECT v.nnet_produkt_ varegruppe_navn , ' .
    > ' f.nnet_produkt_ farge_navn, ' .
    > ' s.nnet_produkt_ storrelse_navn, ' .
    > ' k.nnet_produkt_ kvalitet_navn, ' .
    > ' p.* ' .
    > 'FROM nnet_produkt p, nnet_produkt_va regruppe v, ' .
    > ' nnet_produkt_kv alitet k, nnet_produkt_st orrelse s ' .
    > 'WHERE p.nnet_produkt_ varegruppe_code =
    > v.nnet_produkt_ varegruppe_code ' .
    > ' AND p.nnet_produkt_ farge_code = f.nnet_produkt_ farge_code ' .
    > ' AND p.nnet_produkt_ storrelse_id (+) =
    > s.nnet_produkt_ storrelse_id ' .
    > ' AND p.nnet_produkt_ kvalitet_id (+) =
    > k.nnet_produkt_ kvalitet_id';
    >
    > I am getting "invalid SQL near (+). That is totally VALID SQL syntax for an
    > outer join! If mySQL doesn't allow for that, what am I supposed to do in
    > lieu of the fact that I have to logically join two tables together or if the
    > one is null (the case for an outer join)?
    >
    > Phil
    >
    >[/color]

    Comment

    • Andy Hassall

      #3
      Re: SQL outer join syntax error

      On Fri, 12 Sep 2003 16:28:01 -0400, "Phil Powell" <soazine@erols. com> wrote:
      [color=blue]
      >I am getting "invalid SQL near (+). That is totally VALID SQL syntax for an
      >outer join! If mySQL doesn't allow for that, what am I supposed to do in
      >lieu of the fact that I have to logically join two tables together or if the
      >one is null (the case for an outer join)?[/color]

      (+) is Oracle's outer join syntax, prior to Oracle 9i. 9i now supports the
      ANSI syntax as well, i.e.

      SELECT ... FROM table1 LEFT OUTER JOIN table2 ON (...)

      Join syntax is described in the MYSQL manual, of course:


      --
      Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
      Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

      Comment

      • Phil Powell

        #4
        Re: SQL outer join syntax error

        Sorry my SQL training is solely based on Oracle 7i and 8i terminology. I
        got the SQL query working, just have never seen ANSI syntax before.

        Phil

        "Andy Hassall" <andy@andyh.co. uk> wrote in message
        news:4vc4mv4rvm 81qefhvsqi8mtir c9thrgg2a@4ax.c om...[color=blue]
        > On Fri, 12 Sep 2003 16:28:01 -0400, "Phil Powell" <soazine@erols. com>[/color]
        wrote:[color=blue]
        >[color=green]
        > >I am getting "invalid SQL near (+). That is totally VALID SQL syntax for[/color][/color]
        an[color=blue][color=green]
        > >outer join! If mySQL doesn't allow for that, what am I supposed to do in
        > >lieu of the fact that I have to logically join two tables together or if[/color][/color]
        the[color=blue][color=green]
        > >one is null (the case for an outer join)?[/color]
        >
        > (+) is Oracle's outer join syntax, prior to Oracle 9i. 9i now supports[/color]
        the[color=blue]
        > ANSI syntax as well, i.e.
        >
        > SELECT ... FROM table1 LEFT OUTER JOIN table2 ON (...)
        >
        > Join syntax is described in the MYSQL manual, of course:
        > http://www.mysql.com/doc/en/JOIN.html
        >
        > --
        > Andy Hassall (andy@andyh.co. uk) icq(5747695) (http://www.andyh.co.uk)
        > Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)[/color]


        Comment

        Working...