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 8165395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:31:37+00:00 2026-06-06T19:31:37+00:00

How do I do the equivalent statement in MySQL? I want it if input

  • 0

How do I do the equivalent statement in MySQL? I want it if input is a certain value, don’t insert the row. In SQL SERVER, I can just say ROLLBACK. What’s the equivalent command in MySQL? Thank you.

CREATE TRIGGER tr_some_trigger
ON some_table
FOR INSERT
AS 
BEGIN
  IF inserted.topic == 'test' THEN
    ROLLBACK
  ENDIF
END
  • 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-06-06T19:31:38+00:00Added an answer on June 6, 2026 at 7:31 pm

    From this document:

    The trigger cannot use statements that explicitly or implicitly begin
    or end a transaction such as START TRANSACTION, COMMIT, or ROLLBACK.

    So ROLLBACK won’t work inside your trigger, but if the trigger raises an exception/error, it will prevent the insertion to succeed, so what you can do is raise an exception if your condition is met (one way is to call an undefined function).

    For example:

    DELIMITER $$
    
    CREATE
        TRIGGER `db`.`before_insert` BEFORE INSERT
        ON `db`.`dummy_table`
        FOR EACH ROW BEGIN
        IF new.topic = 'test' THEN
            CALL func_1();
        END IF;
    
        END$$
    
    DELIMITER ;
    

    Assuming func_1 doesn’t exist it will prevent your new record of being inserted.

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

Sidebar

Related Questions

What is the MySQL equivalent statement of DBCC INPUTBUFFER(@@SPID) , which lists the sql
Insert...on duplicate key update in MySql is not a sql standard. Can we treat
In MySQL is there the equivalent of MS SQL's RETURN statement in Stored Procedures?
Can someone show me the MySQL equivalent of the following statement (which works in
I'd like to write a single JDBC statement that can handle the equivalent of
What is the equivalent to the following SQL Server statements in DB2? Begin Transaction
I just was wodering if there's an equivalent to MySQL LOAD DATA INFILE statemnent
Is there an equivalent of a SQL IN statement in LINQ to objects?
I'm using SQL Server 2005 for the first time, having mostly worked with MySQL
Is there any single SQL statement equivalent to these? UPDATE table_name SET (a =

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.