我正在尝试熟悉 Mysql 语法。到目前为止我只使用过MSSQL。我下载了 MySQL 查询浏览器并安装了 MySQL 版本 5.1
我想在 MySQL 的结果集选项卡中运行这行代码,但我不断遇到以下错误
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 'declare iCtr int' at line 1
代码:
declare iCtr int;
set iCtr = 1;
while iCtr < 1000
begin
insert into employee (emp_id,emp_first_name,emp_last_name,status_id)
values (iCtr, 'firstName' + iCtr, 'lastName' + iCtr, 1)
set iCtr = iCtr + 1;
end
我只是想填充我的员工表,但我无法超越 MySQL 语法。
最佳答案
来自:http://dev.mysql.com/doc/refman/5.0/en/declare.html
DECLARE is permitted only inside a BEGIN ... END compound statement and must be at its start, before any other statements.
我认为这可能是麻烦所在?
关于MySQL 查询语句错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4613153/