Delimiter//mysql>CREATEPROCEDUREHello() ->SELECT*fromStudent_info;//QueryOK, 0rowsaffected(0.08sec) we can see"/> Delimiter//mysql>CREATEPROCEDUREHello() ->SELECT*fromStudent_info;//QueryOK, 0rowsaffected(0.08sec) we can see">

Home  >  Article  >  Database  >  How can we create a MySQL stored procedure without "BEGIN" and "END"?

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

PHPz
PHPzforward
2023-09-01 17:09:201295browse

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)

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)

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!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete