MySQL Stored Procedure Example - CREATE TABLE SELECT

MySQL Stored Procedure Example - CREATE TABLE SELECT

Open your SQL Query Editor then copy & paste the below code to make a Stored Procedure to create a backup table of IT employees from another MySQL table using CREATE TABLE SELECT MySQL Sub-Query:

delimiter |
CREATE PROCEDURE SP_CREATE_TABLE_SELECT( )
BEGIN  CREATE TABLE employees_it_20110421
   SELECT *
   FROM employees
   WHERE DepartmentID =60;

END;
|

MySQL Stored Procedure Example - CREATE TABLE SELECT - SQL Query Editor Output

Again open your SQL Query Editor then copy & paste the below code to execute the Stored Procedure to make the backup table:

   call SP_CREATE_TABLE_SELECT;

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

 

Related Tutorial Examples

  1. MySQL Stored Procedure: Variable Example
  2. MySQL Stored Procedure: Batch Salary Increment Example
  3. MySQL TRUNCATE TABLE Example
  4. MySQL coalesce() Function Example
  5. MySQL ISNULL() Function Example
  6. MySQL NULL to zero value Example
  7. How To Find MySQL SERVER VERSION Information
  8. 20 steps to make CakePHP Blog Project
  9. step 2: download cakephp and setup cakeblog
  10. PERL Example: Use of Hash Arrays in PERL

No comments:

Post a Comment

leave your comments here..