Reputation: 1712
I am trying to execute below query but mysql says Syntax error: unexpected '@my_var' (at text suffix)
SET @my_var = 1;
INSERT INTO table1(id, myvar)
SELECT * FROM (LAST_INSERT_ID(), @my_var) AS tmp
How can I use declared variable in above query?
Upvotes: 0
Views: 86
Reputation: 36
What you want to select, that you have putted in FROM.
In FROM there must be a table_name and not a column_name or function call.
Upvotes: 1