MySQL Trigger Error when trying to generate end_date from start_date + duration The Next CEO of Stack OverflowMySQL Trigger - update table with value selected from another tableMYSQL trigger returning null errorWhy MySQL is giving this error while creating trigger?MySQL trigger syntax errorSyntax error when trying to insert from a mysql triggermysql calculate duration from two datesGetting MySQL Trigger Errormysql triggers syntax errorMySQL Trigger for aggregating one table's rows to another tableMysql Add days onto date from two different columns

Find a path from s to t using as few red nodes as possible

Strange use of "whether ... than ..." in official text

Arrows in tikz Markov chain diagram overlap

What is a typical Mizrachi Seder like?

What did the word "leisure" mean in late 18th Century usage?

How can I prove that a state of equilibrium is unstable?

Is the 21st century's idea of "freedom of speech" based on precedent?

Creating a script with console commands

Incomplete cube

A hang glider, sudden unexpected lift to 25,000 feet altitude, what could do this?

Man transported from Alternate World into ours by a Neutrino Detector

Does the Idaho Potato Commission associate potato skins with healthy eating?

What is the difference between 서고 and 도서관?

How can I separate the number from the unit in argument?

Finitely generated matrix groups whose eigenvalues are all algebraic

Gauss' Posthumous Publications?

Small nick on power cord from an electric alarm clock, and copper wiring exposed but intact

How dangerous is XSS

Why did the Drakh emissary look so blurred in S04:E11 "Lines of Communication"?

How can a day be of 24 hours?

How to show a landlord what we have in savings?

Can I cast Thunderwave and be at the center of its bottom face, but not be affected by it?

My ex-girlfriend uses my Apple ID to login to her iPad, do I have to give her my Apple ID password to reset it?

What happens if you break a law in another country outside of that country?



MySQL Trigger Error when trying to generate end_date from start_date + duration



The Next CEO of Stack OverflowMySQL Trigger - update table with value selected from another tableMYSQL trigger returning null errorWhy MySQL is giving this error while creating trigger?MySQL trigger syntax errorSyntax error when trying to insert from a mysql triggermysql calculate duration from two datesGetting MySQL Trigger Errormysql triggers syntax errorMySQL Trigger for aggregating one table's rows to another tableMysql Add days onto date from two different columns










0















Error Message



table



Hi



I am receiving this message when I try to use this trigger to calculate a end_date. The duration Integer is from another table. This is being done in MySQL on Mamp enviorment



Any help appreciated



code used
DELIMITER //



CREATE TRIGGER m_duration_ins_tr1



BEFORE INSERT ON memberships
FOR EACH ROW
BEGIN
DECLARE duration INTEGER;
SELECT duration FROM membership_type WHERE
membership_type_id = NEW.member_type;
SET NEW.end_date := DATE_ADD(NEW.start_date, INTERVAL duration MONTH);
END //
DELIMITER ;










share|improve this question
























  • I don't understand why this is a trigger at all!?!

    – Strawberry
    Mar 7 at 20:03















0















Error Message



table



Hi



I am receiving this message when I try to use this trigger to calculate a end_date. The duration Integer is from another table. This is being done in MySQL on Mamp enviorment



Any help appreciated



code used
DELIMITER //



CREATE TRIGGER m_duration_ins_tr1



BEFORE INSERT ON memberships
FOR EACH ROW
BEGIN
DECLARE duration INTEGER;
SELECT duration FROM membership_type WHERE
membership_type_id = NEW.member_type;
SET NEW.end_date := DATE_ADD(NEW.start_date, INTERVAL duration MONTH);
END //
DELIMITER ;










share|improve this question
























  • I don't understand why this is a trigger at all!?!

    – Strawberry
    Mar 7 at 20:03













0












0








0








Error Message



table



Hi



I am receiving this message when I try to use this trigger to calculate a end_date. The duration Integer is from another table. This is being done in MySQL on Mamp enviorment



Any help appreciated



code used
DELIMITER //



CREATE TRIGGER m_duration_ins_tr1



BEFORE INSERT ON memberships
FOR EACH ROW
BEGIN
DECLARE duration INTEGER;
SELECT duration FROM membership_type WHERE
membership_type_id = NEW.member_type;
SET NEW.end_date := DATE_ADD(NEW.start_date, INTERVAL duration MONTH);
END //
DELIMITER ;










share|improve this question
















Error Message



table



Hi



I am receiving this message when I try to use this trigger to calculate a end_date. The duration Integer is from another table. This is being done in MySQL on Mamp enviorment



Any help appreciated



code used
DELIMITER //



CREATE TRIGGER m_duration_ins_tr1



BEFORE INSERT ON memberships
FOR EACH ROW
BEGIN
DECLARE duration INTEGER;
SELECT duration FROM membership_type WHERE
membership_type_id = NEW.member_type;
SET NEW.end_date := DATE_ADD(NEW.start_date, INTERVAL duration MONTH);
END //
DELIMITER ;







mysql triggers mamp






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 7 at 19:58







C.Haugh

















asked Mar 7 at 19:53









C.HaughC.Haugh

32




32












  • I don't understand why this is a trigger at all!?!

    – Strawberry
    Mar 7 at 20:03

















  • I don't understand why this is a trigger at all!?!

    – Strawberry
    Mar 7 at 20:03
















I don't understand why this is a trigger at all!?!

– Strawberry
Mar 7 at 20:03





I don't understand why this is a trigger at all!?!

– Strawberry
Mar 7 at 20:03












2 Answers
2






active

oldest

votes


















0














I think you just need to replace



SELECT duration FROM membership_type WHERE
membership_type_id = NEW.member_type;



with



SET duration = SELECT duration FROM membership_type WHERE membership_type_id = NEW.member_type LIMIT 1;



The bare SELECT was doing nothing to assign to your local variable, but was indeed basically an attempt to return a result set from your trigger as the error suggested.






share|improve this answer






























    0














    trigger event can be INSERT , UPDATE or DELETE . 
    I dont think you can select .
    Try mysql workbench to create trigger






    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      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: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      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%2fstackoverflow.com%2fquestions%2f55051826%2fmysql-trigger-error-when-trying-to-generate-end-date-from-start-date-duration%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









      0














      I think you just need to replace



      SELECT duration FROM membership_type WHERE
      membership_type_id = NEW.member_type;



      with



      SET duration = SELECT duration FROM membership_type WHERE membership_type_id = NEW.member_type LIMIT 1;



      The bare SELECT was doing nothing to assign to your local variable, but was indeed basically an attempt to return a result set from your trigger as the error suggested.






      share|improve this answer



























        0














        I think you just need to replace



        SELECT duration FROM membership_type WHERE
        membership_type_id = NEW.member_type;



        with



        SET duration = SELECT duration FROM membership_type WHERE membership_type_id = NEW.member_type LIMIT 1;



        The bare SELECT was doing nothing to assign to your local variable, but was indeed basically an attempt to return a result set from your trigger as the error suggested.






        share|improve this answer

























          0












          0








          0







          I think you just need to replace



          SELECT duration FROM membership_type WHERE
          membership_type_id = NEW.member_type;



          with



          SET duration = SELECT duration FROM membership_type WHERE membership_type_id = NEW.member_type LIMIT 1;



          The bare SELECT was doing nothing to assign to your local variable, but was indeed basically an attempt to return a result set from your trigger as the error suggested.






          share|improve this answer













          I think you just need to replace



          SELECT duration FROM membership_type WHERE
          membership_type_id = NEW.member_type;



          with



          SET duration = SELECT duration FROM membership_type WHERE membership_type_id = NEW.member_type LIMIT 1;



          The bare SELECT was doing nothing to assign to your local variable, but was indeed basically an attempt to return a result set from your trigger as the error suggested.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Mar 7 at 23:09









          UueerdoUueerdo

          12.3k1816




          12.3k1816























              0














              trigger event can be INSERT , UPDATE or DELETE . 
              I dont think you can select .
              Try mysql workbench to create trigger






              share|improve this answer



























                0














                trigger event can be INSERT , UPDATE or DELETE . 
                I dont think you can select .
                Try mysql workbench to create trigger






                share|improve this answer

























                  0












                  0








                  0







                  trigger event can be INSERT , UPDATE or DELETE . 
                  I dont think you can select .
                  Try mysql workbench to create trigger






                  share|improve this answer













                  trigger event can be INSERT , UPDATE or DELETE . 
                  I dont think you can select .
                  Try mysql workbench to create trigger







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Mar 7 at 19:57









                  Jin ThakurJin Thakur

                  72767




                  72767



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • 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%2fstackoverflow.com%2fquestions%2f55051826%2fmysql-trigger-error-when-trying-to-generate-end-date-from-start-date-duration%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

                      Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                      Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                      Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved