Loading ...
Sorry, an error occurred while loading the content.
 

RE: [SQLQueriesNoCode] need Help with Update

Expand Messages
  • Rob Richardson
    Unless the original poster is using PostgreSQL, the update query is not perfectly fine. According to the PostgreSQL documentation: This command conforms to
    Message 1 of 8 , Oct 12 11:03 AM
      Unless the original poster is using PostgreSQL, the update query is not perfectly fine. According to the PostgreSQL documentation:

      "This command conforms to the SQL standard, except that the FROM and RETURNING clauses are PostgreSQL extensions."
      (source: http://www.postgresql.org/docs/8.4/static/sql-update.html)

      The only way I know of to do what the OP wanted is by using a sub-select, as other responders have suggested.

      RobR

      -----Original Message-----
      From: SQLQueriesNoCode@yahoogroups.com [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Noman Aftab
      Sent: Friday, October 12, 2012 12:44 PM
      To: SQLQueriesNoCode@yahoogroups.com
      Subject: Re: [SQLQueriesNoCode] need Help with Update

      Unless there is any column which is not defined, the query appears to be perfectly fine.
      Share the error details.
       
      Best Wishes,
      Noman Aftab

       
      http://corpus.quran.com/wordbyword.jsp



      ________________________________
      From: faepigrl <faepigrl@...>
      To: SQLQueriesNoCode@yahoogroups.com
      Sent: Friday, 12 October 2012 1:01 AM
      Subject: [SQLQueriesNoCode] need Help with Update


       
      I want to update a field in one table to another table. I think I am really close but I keep getting a syntax error.

      Here is what I am doing.....

      Update BD
      SET BD.F1 = BD.F1 + OD.F1

      From BD

      INNER JOIN OD

      ON (BD.F2 = OD.F2)

      Where BD.F3 = ' F '

      I think I am missing something and I am worried that it is not going to match the data properly. There are other fields that I am wondering if it need to look at to match up....any advice....

      Thanks new to SQL.
    • Rob Richardson
      The original poster s update query is not perfectly fine. There are database systems (PostgreSQL is one of them, and the system I am familiar with) that allow
      Message 2 of 8 , Oct 12 12:21 PM
        The original poster's update query is not perfectly fine.

        There are database systems (PostgreSQL is one of them, and the system I am familiar with) that allow a FROM clause in an UPDATE query, but that is a non-standard extension.

        If we assume standard SQL, then a sub-select will be required.

        RobR

        -----Original Message-----
        From: SQLQueriesNoCode@yahoogroups.com [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Noman Aftab
        Sent: Friday, October 12, 2012 12:44 PM
        To: SQLQueriesNoCode@yahoogroups.com
        Subject: Re: [SQLQueriesNoCode] need Help with Update

        Unless there is any column which is not defined, the query appears to be perfectly fine.
        Share the error details.
         
        Best Wishes,
        Noman Aftab

         
        http://corpus.quran.com/wordbyword.jsp



        ________________________________
        From: faepigrl <faepigrl@...>
        To: SQLQueriesNoCode@yahoogroups.com
        Sent: Friday, 12 October 2012 1:01 AM
        Subject: [SQLQueriesNoCode] need Help with Update


         
        I want to update a field in one table to another table. I think I am really close but I keep getting a syntax error.

        Here is what I am doing.....

        Update BD
        SET BD.F1 = BD.F1 + OD.F1

        From BD

        INNER JOIN OD

        ON (BD.F2 = OD.F2)

        Where BD.F3 = ' F '

        I think I am missing something and I am worried that it is not going to match the data properly. There are other fields that I am wondering if it need to look at to match up....any advice....

        Thanks new to SQL.
      • T p
        dont understandif u want to update A fieldUpdate BD SET BD.F1 = BD.F1 + OD.F1 why do you write + sign? is it a varchar/int or what - otherwise u might have to
        Message 3 of 8 , Oct 14 5:48 AM
          dont understandif u want to update A fieldUpdate BD
          SET BD.F1 = BD.F1 + OD.F1

          why do you write + sign?
          is it a varchar/int or what - otherwise u might have to cast it...
          it shoulc be set bd.f1=od.f1 only if u want to update the field value only with the other tablefieldvalue
          To: SQLQueriesNoCode@yahoogroups.com
          From: rdrichardson@...
          Date: Fri, 12 Oct 2012 18:03:54 +0000
          Subject: RE: [SQLQueriesNoCode] need Help with Update


























          Unless the original poster is using PostgreSQL, the update query is not perfectly fine. According to the PostgreSQL documentation:





          "This command conforms to the SQL standard, except that the FROM and RETURNING clauses are PostgreSQL extensions."


          (source: http://www.postgresql.org/docs/8.4/static/sql-update.html)





          The only way I know of to do what the OP wanted is by using a sub-select, as other responders have suggested.





          RobR





          -----Original Message-----


          From: SQLQueriesNoCode@yahoogroups.com [mailto:SQLQueriesNoCode@yahoogroups.com] On Behalf Of Noman Aftab


          Sent: Friday, October 12, 2012 12:44 PM


          To: SQLQueriesNoCode@yahoogroups.com


          Subject: Re: [SQLQueriesNoCode] need Help with Update





          Unless there is any column which is not defined, the query appears to be perfectly fine.


          Share the error details.





          Best Wishes,


          Noman Aftab








          http://corpus.quran.com/wordbyword.jsp











          ________________________________


          From: faepigrl <faepigrl@...>


          To: SQLQueriesNoCode@yahoogroups.com


          Sent: Friday, 12 October 2012 1:01 AM


          Subject: [SQLQueriesNoCode] need Help with Update











          I want to update a field in one table to another table. I think I am really close but I keep getting a syntax error.





          Here is what I am doing.....





          Update BD


          SET BD.F1 = BD.F1 + OD.F1





          From BD





          INNER JOIN OD





          ON (BD.F2 = OD.F2)





          Where BD.F3 = ' F '





          I think I am missing something and I am worried that it is not going to match the data properly. There are other fields that I am wondering if it need to look at to match up....any advice....





          Thanks new to SQL.

















          [Non-text portions of this message have been removed]
        Your message has been successfully submitted and would be delivered to recipients shortly.