

- 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 to write a procedure to insert data in the table in phpMyAdmin?
Let us first create a new table and understand the concept in continuation
mysql> create table StoredProcedureInsertDemo -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(20), -> UserAge int -> ); Query OK, 0 rows affected (0.63 sec)
Here is the query to create a stored procedure to insert data in to the table
mysql> DELIMITER // mysql> create procedure procedure_InsertIntoTable(IN FirstName VARCHAR(100),IN Age INT) -> BEGIN -> insert into StoredProcedureInsertDemo(UserName,UserAge) values (FirstName,Age); -> END -> // Query OK, 0 rows affected (0.34 sec) mysql> DELIMITER ;
Call the stored procedure with the help of CALL command as shown below
mysql> call procedure_InsertIntoTable('Larry',23); Query OK, 1 row affected, 1 warning (0.19 sec)
Check the table records once again.
The query is as follows −
mysql> select *from StoredProcedureInsertDemo;
The following is the output
+--------+----------+---------+ | UserId | UserName | UserAge | +--------+----------+---------+ | 1 | Larry | 23 | +--------+----------+---------+ 1 row in set (0.00 sec)
- Related Questions & Answers
- How to write MySQL procedure to insert data into a table?
- Insert data in a table in MySQL stored procedure?
- How can we write MySQL stored procedure to select all the data from a table?
- How can I create a stored procedure to insert values in a MySQL table?
- Create a table inside a MySQL stored procedure and insert a record on calling the procedure
- How to insert Binary data into a table using JDBC?
- Insert the data into Table C IF The data is not in Table B while Comparing to Table A in MySQL?
- Insert data from one table to another in MySQL?
- How to write a common procedure to find and remove duplicates from any table and columns in Oracle?
- How can we insert data into a MySQL table?
- MySQL Stored Procedure to create a table?
- How to insert data into a table with auto-incremented columns using JDBC?
- How to use an OUT parameter / read data with SELECT from table in a MySQL procedure?
- How to insert multiple rows in a table using a single INSERT command in program?
- How to correctly use delimiter in a MySQL stored procedure and insert values?
Advertisements