- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How is it possible for a MySQL trigger to execute multiple statements?
The MySQL trigger can execute multiple statements with the help of BEGIN…END construct. Within the BEGIN block, we can also use another syntax that is permitted within stored routines such as conditionals and loops. For illustrating the concept, we are using the following example of BEFORE INSERT TRIGGER is having the IF conditional statements −
Example
mysql> Create Trigger before_inser_studentage BEFORE INSERT ON student_age FOR EACH ROW BEGIN IF NEW.age < 0 THEN SET NEW.age = 0; ELSEIF NEW.age > 100 THEN SET NEW.age = 100; END IF; END // Query OK, 0 rows affected (0.30 sec)
- Related Articles
- How is it possible to enter multiple MySQL statements on a single line?
- What is MySQL event and how it is related to trigger?
- How to execute multiple select queries in MySQL ?
- What is MySQL trigger and triggering events related to it?
- How can we create multiple MySQL triggers for the same trigger event and action time?
- How to set delay for MySQL trigger/procedure execution?
- Is it possible to calculate a correlation in a MySQL query?
- How can I see how long statements take to execute on the MySQL command line?
- Is it possible to have a function-based index in MySQL?
- Is it possible to utilize $addToSet multiple times in the same update?
- Is it possible to catch multiple Java exceptions in single catch block?
- How can it be possible to invert a string in MySQL?
- How does ‘FOR EACH ROW’ work in the MySQL trigger?
- How to trigger the same function with jQuery multiple events?
- How to ceate MySQL Trigger before Insert?

Advertisements