http://www.perlmonks.org?node_id=174634


in reply to Re: Trouble updating value of variable for a placeholder
in thread Trouble updating value of variable for a placeholder

Thanks for the help. But LIMIT ?,10 should work.

The first value in LIMIT is the offset - which result to start returning from (starts at 0) And the second value is the amount of rows to return.

If the placeholder value equaled 2 then the statement LIMIT 2,10 would yield results 3 - 13. I've put a static value in the LIMIT and it worked correctly.

peppiv
  • Comment on Re: Re: Trouble updating value of variable for a placeholder

Replies are listed 'Best First'.
Re: Re: Re: Trouble updating value of variable for a placeholder
by stajich (Chaplain) on Jun 14, 2002 at 18:06 UTC
    Clearly I was being dumb, sorry that I posted without checking. Lesson learned about how LIMIT should work now.

    There must be something wrong somewhere else as I was actually able to make the following work just fine on mysql with prepare and execute stmts. Try printing out your '$limit' string and/or doing a validate if( $limit !~ /^\d+$/) { die("limit was '$limit' which is NaN"); }

    "SELECT * FROM tablea WHERE id > ? LIMIT ?,?" "SELECT * FROM tablea LIMIT ?,?" "SELECT * FROM tablea LIMIT ?,10" "SELECT id from tablea LIMIT ?,10" "SELECT * from tablea ORDER BY id LIMIT ?,10"