I want to set the limit of shown result from 0 until the value of declared variable. But I found the error when declaring the variable, it said : "#1064 - you have an error in your SQL syntax.". I know that DECLARE
syntax only permitted in the BEGIN ... END
statement. But why I always get an error?
This is what I've try :
BEGIN
DECLARE panjang INT DEFAULT 0
END;
SET panjang := 10;
SELECT * FROM `TABLENAME`
limit 0, panjang
Can you please tell me what is missing here? I'm using mysql version 5.5.34.
If this SELECT is coming from some other programming language (PHP, VB, Java, etc), I suggest you build the SQL there, so you won't have to learn about Stored Procedures.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.