SET @v1 := SELECT COUNT(*) FROM user_rating;
SELECT @v1
當我使用set
變量執行此查詢時,會顯示此錯誤。如何將查詢結果存儲在使用mysql的變量中
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 'SELECT count(*) FROM user_rating' at line 1
Execution Time : 00:00:00:000
Transfer Time : 00:00:00:000
Total Time : 00:00:00:000
(1 row(s) returned)
Execution Time : 00:00:00:343
Transfer Time : 00:00:00:000
Total Time : 00:00:00:343
http://stackoverflow.com/questions/6081436/how-to- use-alias-as-field-in-mysql/6081523#6081523 – 2016-08-31 09:34:15