Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8197021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:39:10+00:00 2026-06-07T05:39:10+00:00

Not sure I’m in the correct here. I have a stored procedure in MySQL,

  • 0

Not sure I’m in the correct here.

I have a stored procedure in MySQL, which limits results like so:

...
ORDER BY param_sort1, param_sort2
LIMIT param_start, param_end
;

Both *param_start* and *param_end* are passing in as integers like so:

...
IN `param_start` INT, 
IN `param_end` INT
...

While this is working on my developement server using the latest MySQL, the production server is still running MySQL 5.0.88 and throws a syntax error on the LIMIT clause. If I comment it out, it works correctly.

I’m fairly new to MySQL and completely clueless regarding how to do this correctly in older versions of MySQL.

Question:
Any tips how to get this working?

THANKS!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:39:12+00:00Added an answer on June 7, 2026 at 5:39 am

    You cannot use variables or parameters for LIMIT arguments in MySQL 5.0. This feature was supported in MySQL 5.5.

    As a workaround – construct a query string and execute it using prepared statements.


    something like this (edited):

    CREATE PROCEDURE procedure(IN param_start INT, IN param_end INT)
    BEGIN
      SET @param_start = param_start;
      SET @param_end = param_end;
      SET @sql = CONCAT('SELECT * FROM table LIMIT ?, ?');
      PREPARE stmt FROM @sql;
      EXECUTE stmt USING @param_start, @param_end;
      DEALLOCATE PREPARE stmt;
    END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Not sure if this is the correct Stack Exchange website but here goes.. A
not sure what i'm missing, but here ti go's: i have a floating left
Not sure what exactly is going on here, but seems like in .NET 1.1
Not sure if I can word this right but here we go. I have
Not sure if this is possible in Python, but I'd like to have an
Not sure whats going on here, or what could be the integer in this
Not sure if im just being stupid or something but here goes i work
Not sure how to ask this, but i'll give it a try: I have
not sure what I'm missing here, but i keep getting the error. SQLSTATE[HY093]: Invalid
Not sure what I am doing wrong. The results I get from the Accelerate

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.