SET @v1 := SELECT COUNT(*) FROM user_rating;
SELECT @v1
当我使用 set
变量执行此查询时,会显示此错误.
When I execute this query with set
variable this error is shown.
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
用括号括起来的选择.
SET @v1 := (SELECT COUNT(*) FROM user_rating);
SELECT @v1;
这篇关于如何使用mysql将查询结果存储在变量中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!