0
我試圖執行在SQLyog的這是如何在MySQL中執行存儲在變量中的查詢?
SET @adm_code = 12781;
SET @transfer = (SELECT MAX(id) FROM std_transfer_history AS sth
WHERE admission_code = @adm_code);
EXECUTE @transfer;
查詢,但它給出了一個錯誤
Query: execute @transfer
Error Code: 1064
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@transfer' at line 1
Execution Time : 0 sec
Transfer Time : 0 sec
Total Time : 0 sec
因此,如何能我會擺脫....
我建議*檢查對應於您的MySQL服務器版本的手冊,以獲得*'EXECUTE'的正確語法。對於MySQL 5.7,例如https://dev.mysql.com/doc/refman/5.7/en/sql-syntax-prepared-statements.html。 – LSerni