Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6784011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:56:20+00:00 2026-05-26T16:56:20+00:00

Spent about one hour to understand. Where is this sql trigger contain syntax error?

  • 0

Spent about one hour to understand.
Where is this sql trigger contain syntax error?

CREATE
TRIGGER playlis_trubric_count_on_playlist_shared_update
AFTER UPDATE ON playlist_playlist
  FOR EACH ROW
    IF (NEW.shared != OLD.shared) AND (NEW.shared = 1) THEN
        UPDATE etv.playlist_playlistrubric 
            SET count = playlist_playlistrubric.count + 1
        WHERE etv.playlist_playlistrubric.id = NEW.rubric_id;
    ELSEIF (NEW.shared != OLD.shared) AND (NEW.shared = 0) THEN
        UPDATE etv.playlist_playlistrubric
            SET count = playlist_playlistrubric.count - 1
        WHERE etv.playlist_playlistrubric.id = NEW.rubric_id
    END IF;

ERROR SAYS:

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 ‘ELSEIF (NEW.shared != OLD.shared) AND (NEW.shared = 0) THEN
UPDATE etv.p’ at line 1

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T16:56:20+00:00Added an answer on May 26, 2026 at 4:56 pm

    From the documentation:

    By using the BEGIN ... END construct, you can define a trigger that
    executes multiple statements.
    Within the BEGIN block, you also can use
    other syntax that is permitted within stored routines such as
    conditionals and loops. However, just as for stored routines, if you
    use the mysql program to define a trigger that executes multiple
    statements, it is necessary to redefine the mysql statement delimiter
    so that you can use the ; statement delimiter within the trigger
    definition.
    The following example illustrates these points. It defines
    an UPDATE trigger that checks the new value to be used for updating
    each row, and modifies the value to be within the range from 0 to 100.
    This must be a BEFORE trigger because the value needs to be checked
    before it is used to update the row:

    mysql> delimiter //
    mysql> CREATE TRIGGER upd_check BEFORE UPDATE ON account
        -> FOR EACH ROW
        -> BEGIN
        ->     IF NEW.amount < 0 THEN
        ->         SET NEW.amount = 0;
        ->     ELSEIF NEW.amount > 100 THEN
        ->         SET NEW.amount = 100;
        ->     END IF;
        -> END;//
    mysql> delimiter ;
    

    You’re missing BEGIN and END and you’re also going to need the delimiter trick, because at present your trigger definition ends at the first NEW.rubric_id (which is why the parse error occurs just after that point).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've spent the morning reading through page after page of StackOverflow posts about this
I spent about 4 hours yesterday trying to fix this issue in my code.
I spent about hour and did not find any clue how to highlight my
I have spent about half a day searching for an answer to this question
http://support.microsoft.com/kb/953102 We spent about 50 hours during Christmas holiday to identify this problem, causing
I've spent about 10 hours trying to find this bug that was causing my
I have spent hours on this and read everybit on the web about memory
I just spent about four hours tracking down this problem. I know what is
I spent a lot of time recently reading about debugging. One of the aspects
How exactly does one go about such a simple thing in this beautifully over-complicated

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.