The goal
Concatenate a parameter with a %
operator of LIKE using MySQL.
The problem
There's the following query on my database and it returns me the results very well:
SELECT people.LOGIN, people.EMAIL FROM people
WHERE people.LOGIN LIKE 'o%'
ORDER BY people.LOGIN ASC
LIMIT 10;
But I want to call this function using a Stored Procedure, and instead of use 'o%'
, I want to use '<myvariable>%'
and I'm not managing to do this.
The scenario
I've tried the following on my procedure:
BEGIN
SELECT people.EMAIL FROM people
WHERE people.LOGIN LIKE CONCAT(expression, '%')
ORDER BY people.LOGIN ASC
LIMIT 10;
END
The result? Empty. This query returns me nothing.
Someone has any idea to help me?