Home > Database > Mysql Tutorial > body text

How can we create a MySQL stored procedure without 'BEGIN' and 'END'?

PHPz
Release: 2023-09-01 17:09:20
forward
1251 people have browsed it

How can we create a MySQL stored procedure without BEGIN and END?

We can create MySQL stored procedures without "BEGIN" and "END" just like creating stored procedures using them, the only thing is to omit BEGIN and END. In the example below, we create a stored procedure without "BEGIN" and "END" to get all the rows in the table -

Example

mysql> Delimiter //
mysql> CREATE PROCEDURE Hello()
    -> SELECT * from Student_info; //
Query OK, 0 rows affected (0.08 sec)
Copy after login

We can see that MySQL creates Stored procedures do not have BEGIN and END. Now call it via CALL statement -

mysql> Delimiter ;

mysql> CALL Hello();
+-----+---------+------------+------------+
| id  | Name    | Address    | Subject    |
+-----+---------+------------+------------+
| 101 | YashPal | Amritsar   | History    |
| 105 | Gaurav  | Chandigarh | Literature |
| 125 | Raman   | Shimla     | Computers  |
+------+---------+------------+------------+
3 rows in set (0.18 sec)
Query OK, 0 rows affected (0.28 sec)
Copy after login

The above is the detailed content of How can we create a MySQL stored procedure without 'BEGIN' and 'END'?. For more information, please follow other related articles on the PHP Chinese website!

source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!