Problem 日本語 ver I want to use this query in PROCEDURE. SET @user_variable = FLOOR(RAND()*10); INSERT INTO Table_name (columns_name) VALUES (1) FROM Table_name ORDER BY RAND() LIMIT 1 OFFSET @user_variable; This query want to substitute 1 for the @user_variable 'th line of columns_name, but this query does not work. A cause is that LIMIT and OFFSET does not user variable. Solution SET @user_variable = FLOOR(RAND()*10); PREPARE SET_STMT FROM 'INSERT INTO Table_name (columns_name) VALUES (1) FROM Table_name ORDER BY RAND() LIMIT 1 OFFSET ?;'; EXECUTE SET_STMT USING @user_variable; Conclusion, if you want to use user variable with LIMIT or OFFSET, use PREPARE STATMENT. Reference http://techtipshoge.blogspot.com/2011/10/limit.html
This blog is my learning memo. I write post about ML, math, programing, other. Please click slidebar icon to look for post by contents. content name of post written by Japanese is written Japanese. content name of post written by English is written English. Please look at my post to enjoy and learn ML.