
- 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
How can we write MySQL stored procedure to select all the data from a table?
To demonstrate it we are creating a procedure named ‘selectdetails()’ which will fetch all the records from table ‘student_detail’.
mysql> Delimiter // mysql> Create Procedure selectdetails() -> BEGIN -> Select * from student_detail; -> END// Query OK, 0 rows affected (0.00 sec)
Now, after invoking this procedure, we will get all the records from ‘student_detail’ table.
mysql> Delimiter ; mysql> CALL selectdetails(); +-----------+-------------+------------+ | Studentid | StudentName | address | +-----------+-------------+------------+ | 100 | Gaurav | Delhi | | 101 | Raman | Shimla | | 103 | Rahul | Jaipur | | 104 | Ram | Chandigarh | | 105 | Mohan | Chandigarh | +-----------+-------------+------------+ 5 rows in set (0.00 sec) Query OK, 0 rows affected (0.01 sec)
- Related Articles
- How can we write MySQL handler in a stored procedure?
- How can we alter a MySQL stored procedure?
- How can we drop a MySQL stored procedure?
- How can we invoke MySQL stored procedure?
- How can I create a stored procedure to select values on the basis of some conditions from a MySQL table?
- How can I create a stored procedure to delete values from a MySQL table?
- How can we create a MySQL stored function that uses the dynamic data from a table?
- Insert data in a table in MySQL stored procedure?
- How can we create MySQL stored procedure to calculate the factorial?
- How can we export all the data from MySQL table into a text file?
- How can we export all the data from MySQL table into a CSV file?
- How to write MySQL procedure to insert data into a table?
- How to select all the data from a table using MySQL in Python?
- 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?

Advertisements