1

I'm trying to build a query with a variable limit. As far as I know I cannot do something like select * from table limit my_variable;, but I've read on the internet about a workaround:

SET SQL_SELECT_LIMIT = variable;

I have to write this syntax before the query I want to apply the LIMIT in. This works fine if I write a SELECT query after that code line, but it does not work if I write the following code instead:

INSERT INTO table
SELECT * FROM table1;

It will insert every record of the table1 in table2, instead of inserting the quantity of records specified in the first code line I wrote in this post.

How can I accomplish this?

1 Answer 1

1

Using prepared statements to dynamically compose SQL queries.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.