create PROCEDURE get_users(page_from INT, page_size INT) begin SET @_page_from = page_from; SET @_page_size = page_size; PREPARE stmt FROM "select u.user_id, u.firstname, u.lastname from users u limit ?, ?;"; EXECUTE stmt USING @_page_from, @_page_size; DEALLOCATE PREPARE stmt; end USAGE call get_users(1, 10);
用动态sql吧。