MySQL Stored Procedure Example - INSERT INTO SELECT

MySQL Stored Procedure Example - INSERT INTO SELECT

Open your SQL Query Editor then copy & paste the below code to make a Stored Procedure to insert some data from another table using MySQL INSERT INTO SELECT Sub-Query:

delimiter |
CREATE PROCEDURE SP_INSERT_INTO_SELECT( ) BEGIN INSERT INTO test(TestName)
SELECT FirstName
FROM employees
WHERE EmployeeID >102;

END;
|

MySQL Stored Procedure Example - INSERT INTO SELECT - SQL Query Editor Output

Again open your SQL Query Editor then copy & paste the below code to execute the Stored Procedure to get the desired result:

   CALL SP_INSERT_INTO_SELECT;

MySQL Stored Procedure Example - Executing Stored Procedure - SQL Query Editor Output

 

Related Tutorial Examples

  1. MySQL Stored Procedure Function: Making hello world Function using aliase Example
  2. Operator precedence in SQL Command MySQL Example
  3. Arithmetic operators in SQL Command MySQL Example
  4. Describe Table Structure using SQL Command MySQL Example
  5. MySQL TRUNCATE TABLE Example
  6. PHP String Function Example: implode() - returns formated string on the fly from an array
  7. Google Maps Static API Example Class Using PHP
  8. Regular Expression Example: Email Address Validation Using PHP
  9. 20 steps to make CakePHP Blog Project
  10. PERL Example: Use of Multidimentional Array in PERL

No comments:

Post a Comment

leave your comments here..