How to declare variable in mysql trigger?



How to declare variable in mysql trigger?..

Answer / Santosh Kumar Bhart

To declare a variable inside a MySQL trigger, you can use the DECLARE keyword followed by the variable name and data type. For example: 'CREATE TRIGGER my_trigger BEFORE INSERT ON my_table FOR EACH ROWn BEGINn DECLARE new_id INT;n SET new_id = (SELECT LAST_INSERT_ID());n END;'.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More MySQL Interview Questions

How to use count function in mysql?

1 Answers  


How can we know the number of days between two given dates using MySQL?

2 Answers   Base2 Infotech, Webworks,


How do I show columns in mysql?

1 Answers  


How to enable or disable a row of a table using MySQL in struts?

1 Answers  


How do I start mysql in ubuntu?

1 Answers  


what is a cursor? : Mysql dba

1 Answers  


What are the different types of triggers in mysql?

1 Answers  


Can we rename database in mysql?

1 Answers  


In how many ways we can retrieve data in the result set of mysql using php?

1 Answers  


How to insert html code into mysql database using php?

1 Answers  


how to connect a php script with the mysql database?

1 Answers  


Is mysql relational?

1 Answers  


Categories