Some instances understand the mysql database stored procedures and mysql database Stored Procedures
Mysql stored procedure: encapsulate SQL:
Create procedure p1 () beginselect * from t_news; end $ // simple mysql Stored procedure instanceDisplay stored procedure information: \ G (horizontal table uses vertical table output)
Create procedure p2 (n int) # beginselect * from t_category where cid> n; end $
Create procedure p3 (n int, j char (1 )) # begin if j = 'H' then # different from other languages, the then symbol must be added. Note: = Not = select * from t_category where cid> n; elseselect * from t_category where cid <n; end if; end $
Create procedure p4 (n smallint) # include the parameter begin declare I int; declare s int; set s = 0; set I = 1; while I <= n doset s = s + I; set I = I + 1; end while; select s; end $
Two key points:
First, whether your access user has the same permissions for this table. If so, everything is simple.
Second, when you describe a table, you only need to add a database name. Select wc. table. name from wc. table, wcw. table2.name
How to view the execution of stored procedures in the mysql database
Execute the Stored Procedure statement step by step !! View the results of each statement! 1
In this way, we can check whether the execution conditions are correct or not.