MySQL in limit uses dynamic parameter resolution (stitching SQL string statements to execute SQL)

Source: Internet
Author: User

The official seems to have said that limit has supported dynamic parameters on version 5.6, but it still doesn't work when testing.

The only way to solve the limit dynamic parameter is to use a string of SQL concatenation and then execute it.

Generally there are the following ways to solve:

1, the storage process splicing

2. Function stitching

3. Stitching in view

4. Use in session of current query

In fact, this is the same meaning, is to use a variable to access the SQL, and then execute the variable.

Examples:

Set @stmt =Concat'SELECT * from', TABLE_NAME,'Limit?,?');PrepareS1 from @stmt;Set @s1 =Page_begin;Set @s2 =Page_end;ExecuteS1 using@s1,@s2;deallocate PrepareS1;

Reference:

http://blog.csdn.net/hellolongbin/article/details/1999817

http://blog.csdn.net/yongsheng0550/article/details/6217917

http://blog.csdn.net/xinyuan_java/article/details/50056741

MySQL in limit uses dynamic parameter resolution (stitching SQL string statements to execute SQL)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.