具有动态变量的存储过程
我正在从 YouTube 学习 MySQL。我处于初级水平。我想知道为什么我们使用 @F_emps 。 这里
创建新表
create table employees_detailss (
Emp_id int primary key,
Emp_name varcharacter (28),
Age int,
Gender character (10),
Department varcharacter (25),
City character (22),
salary float
);
以了解如何向表元素
describe employees_details ;
插入值
Insert into employees_detailss
values
( 5524, "Jimmie Clayton", 44,"M", "Marketing", "Berlin", 35000),
(2174, "Clyde Turner", 34, "F" , "Finance", "Paris", 23000),
(4141, "Carol Hubbard" , 37, "M", "IT","Rome", 45000),
(6182, " Dennis Flores" , 45, "M", "Supply chain", " Venis", 28000),
(5324, "Stewart Bowers", 47 , "F" , "IT", " London" , 50000),
(7446, "Nichole Bush", 27, "M" ,"Marketing", "Lisbon", 20000),
(965, "Anne Brady", 32, "F", "Finance", "Berlin",28000),
(6177, "Kristina Riley",36,"F", "Supply chain", "Milan", 34000),
(4855, "Evan Martin", 34,"M", "Finance", "Soest",29000),
(5899, "Josephine Mason", 47, "M", "IT", "Dresden", 44000),
(1994, "Manuel Houston",33,"F", "Marketing", "Munich", 42000),
(387, "Robyn Fernandez", 27, "M", "Finance", "Postdam",40000),
(2125, "Bessie Richardson", 35, "F", "IT", "Hamburg", 34000),
(8180, "Christie Henderson", 33, "F", "Marketing", "Cottbus", 44000);
select * from employees_detailss ;
delimiter //
create Procedure Sp_CountEmployeesss ( out Total_emps int )
begin
select count(Emp_name) into Total_emps from employees_detailss
where Gender = "F";
end //
delimiter ;
call Sp_CountEmployeesss(@F_emps);
select @F_emps as Female_Emps;
I am learning MySQL from YouTube. I am at beginner level . I want to know why we use @F_emps .
here
to create new table
create table employees_detailss (
Emp_id int primary key,
Emp_name varcharacter (28),
Age int,
Gender character (10),
Department varcharacter (25),
City character (22),
salary float
);
to know how the table elements
describe employees_details ;
to insert values
Insert into employees_detailss
values
( 5524, "Jimmie Clayton", 44,"M", "Marketing", "Berlin", 35000),
(2174, "Clyde Turner", 34, "F" , "Finance", "Paris", 23000),
(4141, "Carol Hubbard" , 37, "M", "IT","Rome", 45000),
(6182, " Dennis Flores" , 45, "M", "Supply chain", " Venis", 28000),
(5324, "Stewart Bowers", 47 , "F" , "IT", " London" , 50000),
(7446, "Nichole Bush", 27, "M" ,"Marketing", "Lisbon", 20000),
(965, "Anne Brady", 32, "F", "Finance", "Berlin",28000),
(6177, "Kristina Riley",36,"F", "Supply chain", "Milan", 34000),
(4855, "Evan Martin", 34,"M", "Finance", "Soest",29000),
(5899, "Josephine Mason", 47, "M", "IT", "Dresden", 44000),
(1994, "Manuel Houston",33,"F", "Marketing", "Munich", 42000),
(387, "Robyn Fernandez", 27, "M", "Finance", "Postdam",40000),
(2125, "Bessie Richardson", 35, "F", "IT", "Hamburg", 34000),
(8180, "Christie Henderson", 33, "F", "Marketing", "Cottbus", 44000);
select * from employees_detailss ;
delimiter //
create Procedure Sp_CountEmployeesss ( out Total_emps int )
begin
select count(Emp_name) into Total_emps from employees_detailss
where Gender = "F";
end //
delimiter ;
call Sp_CountEmployeesss(@F_emps);
select @F_emps as Female_Emps;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当您进行调用时:
这意味着您将一个变量传递给
Sp_CountEmployeesss
来存储结果。然后,在调用行之后,数据将保存在@F_emps
中,因此您将执行选择来查询结果并查看计算的数据。When you do the call:
What it means is that you pass a variable to
Sp_CountEmployeesss
to store the result(s). Then after the call's line, the data is saved in@F_emps
so you'll do a select to query the result and see the calculated data.