How do I use variables to represent string values in MySQL? The stored procedure below has two variables @varname and @file1. It also uses concat() to create a string from @file1, but none of these string values is populating properly into the script. (The query is not loading results and the outfile is not being created.) How can I fix this code so that it works?
DELIMITER $$
DROP PROCEDURE IF EXISTS `parse_descriptions`$$
CREATE PROCEDURE `parse_descriptions`()
BEGIN
SET @varname='something';
SET @file1= concat('D:/mypath/','@varname');
select d.id, d.term, d.conceptid from dtablename as d
where term like '%@varname%'
into outfile concat('@file1','_test.txt')
fields terminated by '\t'
optionally enclosed by ""
lines terminated by '\r\n'
;
END$$
CALL `parse_descriptions`()$$
DROP PROCEDURE IF EXISTS `parse_descriptions`$$
SET @file1= concat('D:/mypath/',@varname);by removing the quote around the parameter.