this query fails, why?

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

    this query fails, why?

    Ok guys, here we go again!

    SELECT s.nnet_produkt_ storrelse_navn
    FROM nnet_produkt_st orrelse s, nnet_produkt_va regruppe v,
    nnet_storrelse_ varegruppe_asso c sv, nnet_produkt p
    WHERE s.nnet_produkt_ storrelse.id = sv.nnet_produkt _storrelse_id
    AND sv.nnet_produkt _varegruppe_id = v.nnet_produkt_ varegruppe_id
    AND sv.nnet_produkt _varegruppe_id IN (
    SELECT nnet_produkt_va regruppe_id
    FROM nnet_produkt_va regruppe
    WHERE nnet_produkt_va regruppe_code = 'FLU17'
    )
    AND p.nnet_produkt_ storrelse_id > 1

    This produces the following error:

    You have an error in your SQL syntax near 'SELECT nnet_produkt_va regruppe_id
    FROM nnet_produkt_va regruppe WHERE nnet_produk' at line 1
    I don't see anything wrong with this query, it's standard inner SELECT
    stuff! I need help... again!

    Phil


    ----------------------------------------------------------------------------
    ----


    _______________ _______________ _______________ __
    talk mailing list
    talk@lists.nyph p.org



  • Louis-Philippe Huberdeau

    #2
    Re: this query fails, why?

    Are you using MySQL 4.1? If not, it's absolutly normal that the query
    does not work since MySQL only supports subqueries since 4.1, which is
    currently an alpha release.

    Phil Powell wrote:[color=blue]
    > Ok guys, here we go again!
    >
    > SELECT s.nnet_produkt_ storrelse_navn
    > FROM nnet_produkt_st orrelse s, nnet_produkt_va regruppe v,
    > nnet_storrelse_ varegruppe_asso c sv, nnet_produkt p
    > WHERE s.nnet_produkt_ storrelse.id = sv.nnet_produkt _storrelse_id
    > AND sv.nnet_produkt _varegruppe_id = v.nnet_produkt_ varegruppe_id
    > AND sv.nnet_produkt _varegruppe_id IN (
    > SELECT nnet_produkt_va regruppe_id
    > FROM nnet_produkt_va regruppe
    > WHERE nnet_produkt_va regruppe_code = 'FLU17'
    > )
    > AND p.nnet_produkt_ storrelse_id > 1
    >
    > This produces the following error:
    >
    > You have an error in your SQL syntax near 'SELECT nnet_produkt_va regruppe_id
    > FROM nnet_produkt_va regruppe WHERE nnet_produk' at line 1
    > I don't see anything wrong with this query, it's standard inner SELECT
    > stuff! I need help... again!
    >
    > Phil
    >
    >
    > ----------------------------------------------------------------------------
    > ----
    >
    >
    > _______________ _______________ _______________ __
    > talk mailing list
    > talk@lists.nyph p.org
    > http://lists.nyphp.org/mailman/listinfo/talk
    >
    >[/color]

    Comment

    • Jan Pieter Kunst

      #3
      Re: this query fails, why?

      In article <cSkbb.3113$sp2 .2606@lakeread0 4>,
      "Phil Powell" <soazine@erols. com> wrote:
      [color=blue]
      > You have an error in your SQL syntax near 'SELECT nnet_produkt_va regruppe_id
      > FROM nnet_produkt_va regruppe WHERE nnet_produk' at line 1
      > I don't see anything wrong with this query, it's standard inner SELECT
      > stuff! I need help... again![/color]

      If you are using MySQL: you can't use subqueries in MySQL yet. They are
      planned for version 4.1, if I remember correctly.

      If you are using another RDBMS that does support subqueries, just echo
      the complete query and the error will usually be obvious.

      JP

      --
      Sorry, <devnull@cauce. org> is een "spam trap".
      E-mail adres is <jpk"at"akamail .com>, waarbij "at" = @.

      Comment

      • Phil Powell

        #4
        Re: this query fails, why?

        Wow. I can't do subqueries, I can't use foreign key constraints, I can't
        even use the now() function for default values in an INSERT statement on a
        datetime column field..

        I can see I won't be doing much in the way of RDM with mySQL. *sigh* Thanx

        Phil

        "Louis-Philippe Huberdeau" <lphuberdeau@sy mpatico.ca> wrote in message
        news:8dlbb.1836 $1H3.25516@news 20.bellglobal.c om...[color=blue]
        > Are you using MySQL 4.1? If not, it's absolutly normal that the query
        > does not work since MySQL only supports subqueries since 4.1, which is
        > currently an alpha release.
        >
        > Phil Powell wrote:[color=green]
        > > Ok guys, here we go again!
        > >
        > > SELECT s.nnet_produkt_ storrelse_navn
        > > FROM nnet_produkt_st orrelse s, nnet_produkt_va regruppe v,
        > > nnet_storrelse_ varegruppe_asso c sv, nnet_produkt p
        > > WHERE s.nnet_produkt_ storrelse.id = sv.nnet_produkt _storrelse_id
        > > AND sv.nnet_produkt _varegruppe_id = v.nnet_produkt_ varegruppe_id
        > > AND sv.nnet_produkt _varegruppe_id IN (
        > > SELECT nnet_produkt_va regruppe_id
        > > FROM nnet_produkt_va regruppe
        > > WHERE nnet_produkt_va regruppe_code = 'FLU17'
        > > )
        > > AND p.nnet_produkt_ storrelse_id > 1
        > >
        > > This produces the following error:
        > >
        > > You have an error in your SQL syntax near 'SELECT[/color][/color]
        nnet_produkt_va regruppe_id[color=blue][color=green]
        > > FROM nnet_produkt_va regruppe WHERE nnet_produk' at line 1
        > > I don't see anything wrong with this query, it's standard inner SELECT
        > > stuff! I need help... again!
        > >
        > > Phil
        > >
        > >[/color]
        >
        > --------------------------------------------------------------------------[/color]
        --[color=blue][color=green]
        > > ----
        > >
        > >
        > > _______________ _______________ _______________ __
        > > talk mailing list
        > > talk@lists.nyph p.org
        > > http://lists.nyphp.org/mailman/listinfo/talk
        > >
        > >[/color]
        >[/color]


        Comment

        • Jan Pieter Kunst

          #5
          Re: this query fails, why?

          In article <j6ubb.5245$sp2 .4830@lakeread0 4>,
          "Phil Powell" <soazine@erols. com> wrote:
          [color=blue]
          > Wow. I can't do subqueries, I can't use foreign key constraints, I can't
          > even use the now() function for default values in an INSERT statement on a
          > datetime column field..[/color]

          I'll be the first to admit that MySQL has its limits, but you can use
          foreign key constraints if you use the InnoDB table type, and you can
          define a field as type 'TIMESTAMP' if you need to automatically enter
          the current date/time on INSERT.

          JP

          --
          Sorry, <devnull@cauce. org> is een "spam trap".
          E-mail adres is <jpk"at"akamail .com>, waarbij "at" = @.

          Comment

          • Louis-Philippe Huberdeau

            #6
            Re: this query fails, why?

            You can't use NOW(), but there is an equivalent somewhere. Just search
            the documentation. As for the foreign keys, they are availible if you
            use InnoDB instead of the default MyISAM. Once again, a simple search in
            the documentation will tell you that it has been availible for a while.

            Phil Powell wrote:[color=blue]
            > Wow. I can't do subqueries, I can't use foreign key constraints, I can't
            > even use the now() function for default values in an INSERT statement on a
            > datetime column field..
            >
            > I can see I won't be doing much in the way of RDM with mySQL. *sigh* Thanx
            >
            > Phil
            >
            > "Louis-Philippe Huberdeau" <lphuberdeau@sy mpatico.ca> wrote in message
            > news:8dlbb.1836 $1H3.25516@news 20.bellglobal.c om...
            >[color=green]
            >>Are you using MySQL 4.1? If not, it's absolutly normal that the query
            >>does not work since MySQL only supports subqueries since 4.1, which is
            >>currently an alpha release.
            >>
            >>Phil Powell wrote:
            >>[color=darkred]
            >>>Ok guys, here we go again!
            >>>
            >>>SELECT s.nnet_produkt_ storrelse_navn
            >>>FROM nnet_produkt_st orrelse s, nnet_produkt_va regruppe v,
            >>>nnet_storrel se_varegruppe_a ssoc sv, nnet_produkt p
            >>>WHERE s.nnet_produkt_ storrelse.id = sv.nnet_produkt _storrelse_id
            >>> AND sv.nnet_produkt _varegruppe_id = v.nnet_produkt_ varegruppe_id
            >>> AND sv.nnet_produkt _varegruppe_id IN (
            >>> SELECT nnet_produkt_va regruppe_id
            >>> FROM nnet_produkt_va regruppe
            >>> WHERE nnet_produkt_va regruppe_code = 'FLU17'
            >>> )
            >>> AND p.nnet_produkt_ storrelse_id > 1
            >>>
            >>>This produces the following error:
            >>>
            >>>You have an error in your SQL syntax near 'SELECT[/color][/color]
            >
            > nnet_produkt_va regruppe_id
            >[color=green][color=darkred]
            >>>FROM nnet_produkt_va regruppe WHERE nnet_produk' at line 1
            >>>I don't see anything wrong with this query, it's standard inner SELECT
            >>>stuff! I need help... again!
            >>>
            >>>Phil
            >>>
            >>>[/color]
            >>
            >>--------------------------------------------------------------------------[/color]
            >
            > --
            >[color=green][color=darkred]
            >>>----
            >>>
            >>>
            >>>____________ _______________ _______________ _____
            >>>talk mailing list
            >>>talk@lists.n yphp.org
            >>>http://lists.nyphp.org/mailman/listinfo/talk
            >>>
            >>>[/color]
            >>[/color]
            >
            >[/color]

            Comment

            • Phil Powell

              #7
              Re: this query fails, why?

              I know about InnoDB but the version of mySQL running on the remote server
              where the client who is paying me to do freelance work for is an older
              version that does not allow for InnoDB to be an option for table type.

              Phil

              "Louis-Philippe Huberdeau" <lphuberdeau@sy mpatico.ca> wrote in message
              news:qkubb.2960 $yD1.280618@new s20.bellglobal. com...[color=blue]
              > You can't use NOW(), but there is an equivalent somewhere. Just search
              > the documentation. As for the foreign keys, they are availible if you
              > use InnoDB instead of the default MyISAM. Once again, a simple search in
              > the documentation will tell you that it has been availible for a while.
              >
              > Phil Powell wrote:[color=green]
              > > Wow. I can't do subqueries, I can't use foreign key constraints, I[/color][/color]
              can't[color=blue][color=green]
              > > even use the now() function for default values in an INSERT statement on[/color][/color]
              a[color=blue][color=green]
              > > datetime column field..
              > >
              > > I can see I won't be doing much in the way of RDM with mySQL. *sigh*[/color][/color]
              Thanx[color=blue][color=green]
              > >
              > > Phil
              > >
              > > "Louis-Philippe Huberdeau" <lphuberdeau@sy mpatico.ca> wrote in message
              > > news:8dlbb.1836 $1H3.25516@news 20.bellglobal.c om...
              > >[color=darkred]
              > >>Are you using MySQL 4.1? If not, it's absolutly normal that the query
              > >>does not work since MySQL only supports subqueries since 4.1, which is
              > >>currently an alpha release.
              > >>
              > >>Phil Powell wrote:
              > >>
              > >>>Ok guys, here we go again!
              > >>>
              > >>>SELECT s.nnet_produkt_ storrelse_navn
              > >>>FROM nnet_produkt_st orrelse s, nnet_produkt_va regruppe v,
              > >>>nnet_storrel se_varegruppe_a ssoc sv, nnet_produkt p
              > >>>WHERE s.nnet_produkt_ storrelse.id = sv.nnet_produkt _storrelse_id
              > >>> AND sv.nnet_produkt _varegruppe_id = v.nnet_produkt_ varegruppe_id
              > >>> AND sv.nnet_produkt _varegruppe_id IN (
              > >>> SELECT nnet_produkt_va regruppe_id
              > >>> FROM nnet_produkt_va regruppe
              > >>> WHERE nnet_produkt_va regruppe_code = 'FLU17'
              > >>> )
              > >>> AND p.nnet_produkt_ storrelse_id > 1
              > >>>
              > >>>This produces the following error:
              > >>>
              > >>>You have an error in your SQL syntax near 'SELECT[/color]
              > >
              > > nnet_produkt_va regruppe_id
              > >[color=darkred]
              > >>>FROM nnet_produkt_va regruppe WHERE nnet_produk' at line 1
              > >>>I don't see anything wrong with this query, it's standard inner SELECT
              > >>>stuff! I need help... again!
              > >>>
              > >>>Phil
              > >>>
              > >>>
              > >>[/color][/color]
              >[color=green]
              >>--------------------------------------------------------------------------
              > >
              > > --
              > >[color=darkred]
              > >>>----
              > >>>
              > >>>
              > >>>____________ _______________ _______________ _____
              > >>>talk mailing list
              > >>>talk@lists.n yphp.org
              > >>>http://lists.nyphp.org/mailman/listinfo/talk
              > >>>
              > >>>
              > >>[/color]
              > >
              > >[/color]
              >[/color]


              Comment

              Working...