I’m using VSC++ and MySQL ver.5.2.25 database, I’ve tested a query In MySQL that is like this:
select Name from test.virus where Name LIKE 'b' '%' ORDER BY Name;
It works well and return all Names that starts with ‘b’,I want to use a routine instead of this query, so that I can call the routine from my program. I’ve tried this:
-- --------------------------------------------------------------------------------
-- Routine DDL
-- --------------------------------------------------------------------------------
DELIMITER $$
CREATE DEFINER=`root`@`localhost` PROCEDURE `StartWith`(NewName VarChar(20))
BEGIN
select NameVirus from test.virus
where NameVirus LIKE "'+NewName+' '%'" ORDER BY NameVirus;
END
When I Call the routine in MySQL there is no error, but the result is an empty table, I guess that the problem is with type of argument, Which type should be the “NewName” parameter?
Advanced thanks for any reply
Your like condition in the example query is flawed. It should be
'b%'.The procedure where clause might need to look like this: