I have a MySQLvariable
@query = CONCAT('INSERT INTO history VALUES (',1,',',50,',UTC_TIMESTAMP()');
I want to execute the insert statement present in the variable.
I have a MySQLvariable
@query = CONCAT('INSERT INTO history VALUES (',1,',',50,',UTC_TIMESTAMP()');
I want to execute the insert statement present in the variable.
You must first prepare the statement using PREPARE and then use EXECUTE
See here: http://dev.mysql.com/doc/refman/5.0/en/sql-syntax-prepared-statements.html
Something like:
SET @query = CONCAT("INSERT INTO history VALUES (",1,",",50,",UTC_TIMESTAMP()");
PREPARE stmt1 FROM @query;
EXECUTE stmt1;
DEALLOCATE PREPARE stmt1;
remove the CONCAT(), it's not doing anything except generate an error since it's trying to concatenate a string with nothing else.
new section and show your skills :)