1 DELIMITER | 2 drop procedure if exists pro_query; 3 CREATE PROCEDURE pro_query 4 ( 5 cname VARCHAR(50) 6 ) 7 BEGIN 8 9 #declare @sql varchar(1000) 10 11 SELECT * ,cname FROM test WHERE (cname ="" or name like CONCAT('%',cname,'%') ); 12 13 END; 14 | 15 DELIMITER ;