concat:拼接的意思,将多个字符串拼接到一起
用法:concat(str1,str2,…)
例如:
-- 创建存储过程,实现查询员工表中姓名含指定字符串的的指定性别的员工有多少人
create procedure show_people(in strname varchar(20),in sex_in varchar(20))
begin
declare e_count int ;
select count(*) into e_count from employee where name like concat('%',strname,'%') and sex = sex_in;
select e_count;
end;
call show_people('陈','男');
这里我将like模糊查询括号中的内容这样写:like concat('%',strname,'%')