Wrong syntax in sql












0















I have a table called sp_en and this table has 2 columns: "no" and "value".
I want to change "value" of row with "no": 4433 to 1 so I enter the command below:



INSERT INTO sp_en (Say) WHERE no='4433' values ("1");


Error returned is:




ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where no='4433'(Say) values ("1")' at line 1




What's the problem. All answers will be appreciated...










share|improve this question


















  • 1





    Did you check the manual?

    – JdeBP
    Mar 11 '17 at 11:53











  • check how? Can you give me any clues about the answer?

    – Konko
    Mar 11 '17 at 11:54






  • 1





    « Check how? » Er. Use your favourite search engine to find the MySQL reference website. Search for the INSERT command. Check the syntax by reading the definition of the INSERT command vs what you have tried to enter.

    – roaima
    Mar 11 '17 at 12:04








  • 1





    @MrLister why? What's strange about that?

    – terdon
    Mar 11 '17 at 12:59






  • 1





    @terdon Because in some systems, stored procedures customarily start with sp_.

    – Mr Lister
    Mar 11 '17 at 13:59
















0















I have a table called sp_en and this table has 2 columns: "no" and "value".
I want to change "value" of row with "no": 4433 to 1 so I enter the command below:



INSERT INTO sp_en (Say) WHERE no='4433' values ("1");


Error returned is:




ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where no='4433'(Say) values ("1")' at line 1




What's the problem. All answers will be appreciated...










share|improve this question


















  • 1





    Did you check the manual?

    – JdeBP
    Mar 11 '17 at 11:53











  • check how? Can you give me any clues about the answer?

    – Konko
    Mar 11 '17 at 11:54






  • 1





    « Check how? » Er. Use your favourite search engine to find the MySQL reference website. Search for the INSERT command. Check the syntax by reading the definition of the INSERT command vs what you have tried to enter.

    – roaima
    Mar 11 '17 at 12:04








  • 1





    @MrLister why? What's strange about that?

    – terdon
    Mar 11 '17 at 12:59






  • 1





    @terdon Because in some systems, stored procedures customarily start with sp_.

    – Mr Lister
    Mar 11 '17 at 13:59














0












0








0


0






I have a table called sp_en and this table has 2 columns: "no" and "value".
I want to change "value" of row with "no": 4433 to 1 so I enter the command below:



INSERT INTO sp_en (Say) WHERE no='4433' values ("1");


Error returned is:




ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where no='4433'(Say) values ("1")' at line 1




What's the problem. All answers will be appreciated...










share|improve this question














I have a table called sp_en and this table has 2 columns: "no" and "value".
I want to change "value" of row with "no": 4433 to 1 so I enter the command below:



INSERT INTO sp_en (Say) WHERE no='4433' values ("1");


Error returned is:




ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'where no='4433'(Say) values ("1")' at line 1




What's the problem. All answers will be appreciated...







linux mysql database






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 11 '17 at 11:52









KonkoKonko

32




32








  • 1





    Did you check the manual?

    – JdeBP
    Mar 11 '17 at 11:53











  • check how? Can you give me any clues about the answer?

    – Konko
    Mar 11 '17 at 11:54






  • 1





    « Check how? » Er. Use your favourite search engine to find the MySQL reference website. Search for the INSERT command. Check the syntax by reading the definition of the INSERT command vs what you have tried to enter.

    – roaima
    Mar 11 '17 at 12:04








  • 1





    @MrLister why? What's strange about that?

    – terdon
    Mar 11 '17 at 12:59






  • 1





    @terdon Because in some systems, stored procedures customarily start with sp_.

    – Mr Lister
    Mar 11 '17 at 13:59














  • 1





    Did you check the manual?

    – JdeBP
    Mar 11 '17 at 11:53











  • check how? Can you give me any clues about the answer?

    – Konko
    Mar 11 '17 at 11:54






  • 1





    « Check how? » Er. Use your favourite search engine to find the MySQL reference website. Search for the INSERT command. Check the syntax by reading the definition of the INSERT command vs what you have tried to enter.

    – roaima
    Mar 11 '17 at 12:04








  • 1





    @MrLister why? What's strange about that?

    – terdon
    Mar 11 '17 at 12:59






  • 1





    @terdon Because in some systems, stored procedures customarily start with sp_.

    – Mr Lister
    Mar 11 '17 at 13:59








1




1





Did you check the manual?

– JdeBP
Mar 11 '17 at 11:53





Did you check the manual?

– JdeBP
Mar 11 '17 at 11:53













check how? Can you give me any clues about the answer?

– Konko
Mar 11 '17 at 11:54





check how? Can you give me any clues about the answer?

– Konko
Mar 11 '17 at 11:54




1




1





« Check how? » Er. Use your favourite search engine to find the MySQL reference website. Search for the INSERT command. Check the syntax by reading the definition of the INSERT command vs what you have tried to enter.

– roaima
Mar 11 '17 at 12:04







« Check how? » Er. Use your favourite search engine to find the MySQL reference website. Search for the INSERT command. Check the syntax by reading the definition of the INSERT command vs what you have tried to enter.

– roaima
Mar 11 '17 at 12:04






1




1





@MrLister why? What's strange about that?

– terdon
Mar 11 '17 at 12:59





@MrLister why? What's strange about that?

– terdon
Mar 11 '17 at 12:59




1




1





@terdon Because in some systems, stored procedures customarily start with sp_.

– Mr Lister
Mar 11 '17 at 13:59





@terdon Because in some systems, stored procedures customarily start with sp_.

– Mr Lister
Mar 11 '17 at 13:59










2 Answers
2






active

oldest

votes


















4














You don't want to insert when the entry you want to modify is already in the table. You probably want to update instead:



UPDATE TABLE sp_en SET Say = 1 WHERE no = 4433;


This will update all rows where the no column has value 4433 and for those rows set Say to 1.



I have assumed integer columns.






share|improve this answer

































    0














    INSERT syntax is only used for inserting new data into the database.
    To update or change the value UPDATE syntax is used:



    UPDATE TABLE table_name
    SET column_name = value
    WHERE column_name = value;


    In above syntax replace lowercase word with their respective values.
    Also, column_name used in SET is the one you want to change while the one used in WHERE is the conditional column.



    So the query becomes:



    UPDATE TABLE so_en
    SET my_column = 1
    WHERE no = 4433;


    Thats all!!!



    P.S You can find this answer easily in google. So it would be better if you do some more research. And this question belongs to dba stackexchange






    share|improve this answer























      Your Answer








      StackExchange.ready(function() {
      var channelOptions = {
      tags: "".split(" "),
      id: "106"
      };
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function() {
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled) {
      StackExchange.using("snippets", function() {
      createEditor();
      });
      }
      else {
      createEditor();
      }
      });

      function createEditor() {
      StackExchange.prepareEditor({
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader: {
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      },
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      });


      }
      });














      draft saved

      draft discarded


















      StackExchange.ready(
      function () {
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f350728%2fwrong-syntax-in-sql%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      2 Answers
      2






      active

      oldest

      votes








      2 Answers
      2






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      4














      You don't want to insert when the entry you want to modify is already in the table. You probably want to update instead:



      UPDATE TABLE sp_en SET Say = 1 WHERE no = 4433;


      This will update all rows where the no column has value 4433 and for those rows set Say to 1.



      I have assumed integer columns.






      share|improve this answer






























        4














        You don't want to insert when the entry you want to modify is already in the table. You probably want to update instead:



        UPDATE TABLE sp_en SET Say = 1 WHERE no = 4433;


        This will update all rows where the no column has value 4433 and for those rows set Say to 1.



        I have assumed integer columns.






        share|improve this answer




























          4












          4








          4







          You don't want to insert when the entry you want to modify is already in the table. You probably want to update instead:



          UPDATE TABLE sp_en SET Say = 1 WHERE no = 4433;


          This will update all rows where the no column has value 4433 and for those rows set Say to 1.



          I have assumed integer columns.






          share|improve this answer















          You don't want to insert when the entry you want to modify is already in the table. You probably want to update instead:



          UPDATE TABLE sp_en SET Say = 1 WHERE no = 4433;


          This will update all rows where the no column has value 4433 and for those rows set Say to 1.



          I have assumed integer columns.







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 3 hours ago

























          answered Mar 11 '17 at 11:56









          KusalanandaKusalananda

          131k17249408




          131k17249408

























              0














              INSERT syntax is only used for inserting new data into the database.
              To update or change the value UPDATE syntax is used:



              UPDATE TABLE table_name
              SET column_name = value
              WHERE column_name = value;


              In above syntax replace lowercase word with their respective values.
              Also, column_name used in SET is the one you want to change while the one used in WHERE is the conditional column.



              So the query becomes:



              UPDATE TABLE so_en
              SET my_column = 1
              WHERE no = 4433;


              Thats all!!!



              P.S You can find this answer easily in google. So it would be better if you do some more research. And this question belongs to dba stackexchange






              share|improve this answer




























                0














                INSERT syntax is only used for inserting new data into the database.
                To update or change the value UPDATE syntax is used:



                UPDATE TABLE table_name
                SET column_name = value
                WHERE column_name = value;


                In above syntax replace lowercase word with their respective values.
                Also, column_name used in SET is the one you want to change while the one used in WHERE is the conditional column.



                So the query becomes:



                UPDATE TABLE so_en
                SET my_column = 1
                WHERE no = 4433;


                Thats all!!!



                P.S You can find this answer easily in google. So it would be better if you do some more research. And this question belongs to dba stackexchange






                share|improve this answer


























                  0












                  0








                  0







                  INSERT syntax is only used for inserting new data into the database.
                  To update or change the value UPDATE syntax is used:



                  UPDATE TABLE table_name
                  SET column_name = value
                  WHERE column_name = value;


                  In above syntax replace lowercase word with their respective values.
                  Also, column_name used in SET is the one you want to change while the one used in WHERE is the conditional column.



                  So the query becomes:



                  UPDATE TABLE so_en
                  SET my_column = 1
                  WHERE no = 4433;


                  Thats all!!!



                  P.S You can find this answer easily in google. So it would be better if you do some more research. And this question belongs to dba stackexchange






                  share|improve this answer













                  INSERT syntax is only used for inserting new data into the database.
                  To update or change the value UPDATE syntax is used:



                  UPDATE TABLE table_name
                  SET column_name = value
                  WHERE column_name = value;


                  In above syntax replace lowercase word with their respective values.
                  Also, column_name used in SET is the one you want to change while the one used in WHERE is the conditional column.



                  So the query becomes:



                  UPDATE TABLE so_en
                  SET my_column = 1
                  WHERE no = 4433;


                  Thats all!!!



                  P.S You can find this answer easily in google. So it would be better if you do some more research. And this question belongs to dba stackexchange







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 11 '17 at 18:50









                  SagaryalSagaryal

                  922311




                  922311






























                      draft saved

                      draft discarded




















































                      Thanks for contributing an answer to Unix & Linux Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid



                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.


                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function () {
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f350728%2fwrong-syntax-in-sql%23new-answer', 'question_page');
                      }
                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      宮崎県

                      How to check if a shell is login/interactive/batch

                      濃尾地震