Stored procedure with a parameter to find match while writing Mysql


Friends know how I can do a stored procedure using like that that receives a parameter, where when I say let's put the letter "a", look for all those that begin with that letter

create procedure sp_busca_albun(
in nombres varchar(200)
select idalbum,nombrealbum,fotoalbum,nombreartista from 
tb_album as tal inner join tb_artista as tar
on tal.idartista=tar.idartista
where  tal.nombrealbum like '%' + nombres + '%' and tal.tipo='FREE';
asked by Chris Alexis 02.12.2018 в 02:37

1 answer


When using the wildcard character at the beginning and end, you will get all the results in which the field "albumname" contains the character you are looking for, that is (with an "a"):

  • hol to
  • a god
  • s a ludo

If you want me to get only those results that start with "a" you should put in the like condition:

like nombres + '%'
answered by 02.12.2018 в 09:14