
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Display table records from a stored procedure in MySQL
Let us first create a table −
mysql> create table DemoTable1933 ( ClientName varchar(20) ); Query OK, 0 rows affected (0.00 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1933 values('Chris Brown'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1933 values('David Miller'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1933 values('Adam Smith'); Query OK, 1 row affected (0.00 sec) mysql> insert into DemoTable1933 values('John Doe'); Query OK, 1 row affected (0.00 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1933;
This will produce the following output −
+--------------+ | ClientName | +--------------+ | Chris Brown | | David Miller | | Adam Smith | | John Doe | +--------------+ 4 rows in set (0.00 sec)
Here is the query to create a stored procedure and set SELECT in it to display records −
mysql> delimiter // mysql> create procedure display_all_records() begin select * from DemoTable1933; end // Query OK, 0 rows affected (0.00 sec) mysql> delimiter ;
Now you can call a stored procedure using call command:
mysql> call display_all_records();
This will produce the following output −
+--------------+ | ClientName | +--------------+ | Chris Brown | | David Miller | | Adam Smith | | John Doe | +--------------+ 4 rows in set (0.00 sec) Query OK, 0 rows affected (0.00 sec)
- Related Articles
- Display records from MySQL stored Procedure with IF…THEN…END IF statements
- Display description of MySQL stored procedure
- MySQL Stored Procedure to create a table?
- Insert data in a table in MySQL stored procedure?
- How to display message from a stored procedure?
- Display selected records from a MySQL table with IN() operator
- MySQL Stored Procedure to update records with certain condition?
- Create a Stored Procedure with MySQL and set a limit to display only a specific number of records
- How can I create a stored procedure to delete values from a MySQL table?
- MySQL stored procedure to execute SHOW CREATE TABLE?
- How can I create a MySQL stored procedure that returns multiple values from a MySQL table?
- How can a MySQL stored procedure call another MySQL stored procedure inside it?
- Create a MySQL stored procedure which fetches the rows from a table by using a cursor?
- How can we write MySQL stored procedure to select all the data from a table?
- Create a table inside a MySQL stored procedure and insert a record on calling the procedure

Advertisements