Results 1 to 2 of 2

Thread: Sql Error, Why?

  1. #1
    Join Date
    Oct 2003
    Posts
    6

    Unanswered: Sql Error, Why?

    UPDATE jose INNER JOIN (SELECT First(jose.a) AS a1, Last(jose.a) AS a2, jose.valor, Count(jose.valor) AS CuentaDevalor FROM jose GROUP BY jose.valor HAVING (((Count(jose.valor))>1))) AS j ON jose.valor = j.valor SET jose.ai = j.a1, jose.af = j.a2;

    I have an error, the query is not actualizable.

    is this sql correct?

  2. #2
    Join Date
    Jan 2005
    Posts
    31
    Quote Originally Posted by kiko123456
    UPDATE jose INNER JOIN (SELECT First(jose.a) AS a1, Last(jose.a) AS a2, jose.valor, Count(jose.valor) AS CuentaDevalor FROM jose GROUP BY jose.valor HAVING (((Count(jose.valor))>1))) AS j ON jose.valor = j.valor SET jose.ai = j.a1, jose.af = j.a2;

    I have an error, the query is not actualizable.

    is this sql correct?
    Here is the above query aligned for readability:

    Code:
    UPDATE jose
           INNER JOIN
           (SELECT First(jose.a) AS a1
                  ,Last(jose.a) AS a2
                  ,jose.valor
                  ,Count(jose.valor) AS CuentaDevalor
              FROM jose
          GROUP BY jose.valor
            HAVING (((Count(jose.valor))>1))) AS j
                ON jose.valor = j.valor
       SET jose.ai = j.a1
          ,jose.af = j.a2;

    Air Code:

    Code:
    UPDATE jose AS J1
           INNER JOIN
           (SELECT First(J0.a) AS a1
                  ,Last(J0.a) AS a2
                  ,jose.valor
                  ,Count(J0.valor) AS CuentaDevalor
              FROM jose AS J0
          GROUP BY J0.valor
            HAVING Count(J0.valor) > 1 ) AS j
        ON J1.valor = j.valor
       SET J1.ai = j.a1
          ,J1.af = j.a2;
    The above will save without syntax errors.

    It is obviously untested.

    The outer ON will have to match the primary keys of the table/query and the subquery . . .

    Note: Even though it saves, I'm not sure the JOIN done is an Updateable Query, and if it's not, then it won't matter how correct the syntax is, the UPDATE won't work.

Posting Permissions

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