開(kāi)發(fā)提了一個(gè)需要分頁(yè)的存儲(chǔ)過(guò)程需求,剛來(lái)時(shí)理解是,只要帶入一個(gè)變量,根據(jù)變量計(jì)算下值,就直接分頁(yè)實(shí)現(xiàn)了...可結(jié)果,創(chuàng)建存儲(chǔ)過(guò)程的時(shí)候報(bào)錯(cuò)了...查了很多資料,后來(lái)才得知,limit后面不能帶變量.于是就想到直接吧帶入?yún)?shù)進(jìn)行計(jì)算.在吧帶入?yún)?shù)進(jìn)行分頁(yè)...
把大概過(guò)程貼一下...自己也記錄一下:
mysql>delimiter //
mysql> create procedure t2 ( d1 int)
-> begin
-> set @a=(d1-1)*10;
-> select * from t1 limt @a,1;
-> end//
ERROR 1064 (42000): 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 '@a,1;
end' at line 4