有人告诉哪里有错误?
CREATE PROCEDURE catalog_get_departments_list()
BEGIN
SELECT department_id, name FROM department ORDER BY department_id;
END$$
这个错误崩溃了:
#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 '' at line 3
答案 0 :(得分:2)
我认为你应该在最后删除美元:
CREATE PROCEDURE catalog_get_departments_list()
BEGIN
SELECT department_id, name FROM department ORDER BY department_id;
END
或设置分隔符
DELIMITER $$
CREATE PROCEDURE catalog_get_departments_list()
BEGIN
SELECT department_id, name FROM department ORDER BY department_id;
END$$
答案 1 :(得分:0)
MySQL客户端的另一个变种 -
CREATE PROCEDURE catalog_get_departments_list()
SELECT department_id, name FROM department ORDER BY department_id;