-- The following is an example of a MySQL concatenation string statement: -- assign a value to the variable to be spliced: SET @ VARNAME
-- The following is an example of a MySQL concatenation string statement: -- assign a value to the variable to be spliced: SET @ VARNAME =
-- The following is an example of MySQL statement for concatenating strings:
-- Assign values to the variables to be spliced
SET @ VARNAME = 'lil ';
-- Concatenate a string, where? Is the parameter for executing the concatenated string statement, and @ TestName is the result value.
SET @ SQLStr0 = CONCAT ('select TestName INTO @ TestName FROM test. t_TestTable WHERE Test_ID>? AND TestName LIKE "% ', @ VARNAME,' %" LIMIT 1 ;');
-- Pre-processing the spliced string
PREPARE SQLStr1 FROM @ SQLStr0;
-- Assign values to parameters
SET @ Test_ID = 1;
-- Run the concatenated string statement using parameters
EXECUTE SQLStr1 USING @ Test_ID;
-- Release the concatenated string statement
Deallocate prepare SQLStr1;
SELECT @ TestName; -- get the result value
-- If you do not need to splice variables or directly use parameters, you can start preprocessing directly.
-- Pre-processing the spliced string
PREPARE SQLStr1 FROM 'select TestName INTO @ TestName FROM test. t_TestTable WHERE Test_ID>? AND TestName LIKE "%? % "LIMIT 1 ;';
-- Assign values to parameters
SET @ Test_ID = 1;
SET @ VARNAME = 'lil ';
-- Run the concatenated string statement using parameters
EXECUTE SQLStr1 USING @ Test_ID, @ VARNAME;
-- Release the concatenated string statement
Deallocate prepare SQLStr1;
SELECT @ TestName; -- get the result value
,