如何编写 MySQL 存储过程来从表中选取所有数据?
mysqlmysqli database
为了演示,我们创建了一个名为"selectdetails()"的过程,它将从表"student_detail"中获取所有记录。
mysql> Delimiter // mysql> Create Procedure selectdetails() -> BEGIN -> Select * from student_detail; -> END// Query OK, 0 rows affected (0.00 sec)
现在,调用此过程后,我们将从‘student_detail’表中获取所有记录。
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)