
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Questions & Answers
- How is it possible to enter multiple MySQL statements on a single line?
- What is MySQL event and how it is related to trigger?
- What is MySQL trigger and triggering events related to it?
- How to execute multiple select queries in MySQL ?
- Is it possible to calculate a correlation in a MySQL query?
- Is it possible to have a function-based index in MySQL?
- How to set delay for MySQL trigger/procedure execution?
- Is it possible to catch multiple Java exceptions in single catch block?
- Is it possible to utilize $addToSet multiple times in the same update?
- Insert the results of a MySQL select? Is it possible?
- How can we create multiple MySQL triggers for the same trigger event and action time?
- MySQL query to get result from multiple select statements?
- How can it be possible to invert a string in MySQL?
- Is it possible for a politically funded media channel to avoid yellow journalism?
- How can I see how long statements take to execute on the MySQL command line?
Advertisements