我在MySQL中的SQLYog中编写了一个存储过程,如下所示,
DELIMITER $$
如果存在,则删除程序
test
。spUser
$$CREATE PROCEDURE
test
。spUser
(IN start1 INT,IN limit1 INT)BEGIN
选择gi.id,gi.user_id,concat(concat(first_name,''),last_name)作为full_name从generic作为gi,profile作为p其中gi.user_id = p.user_id limit start1,limit1;
END$$
DELIMITER;
如果我已经编写了上面的代码,那么它会抛出错误号。 1064如果我已经将限制start1,limit1替换为限制5,10,那么它将正常运行。
如何解决此问题?
答案 0 :(得分:1)
drop procedure if exists list_users;
delimiter #
create procedure list_users()
begin
set SQL_SELECT_LIMIT = 1;
select * from users;
set SQL_SELECT_LIMIT = DEFAULT;
end#
delimiter ;
select * from users;
+---------+----------+
| user_id | username |
+---------+----------+
| 3 | alpha |
| 2 | bar |
| 4 | beta |
| 1 | f00 |
+---------+----------+
4 rows in set (0.00 sec)
call list_users();
+---------+----------+
| user_id | username |
+---------+----------+
| 3 | alpha |
+---------+----------+
1 row in set (0.00 sec)