SQL Statement Stitching technique (reduces program bloat due to judging conditions)

Source: Internet
Author: User

A fixed SQL we can spell this: SELECT * from Lccont where ID < $ ORDER by ID, but what if we don't know the criteria for the query?

If each condition is changed to determine whether the first condition is too bloated for the program, we can spell the fixed section of SQL as: "SELECT * from Lccont where 1=1", so that we can directly append "and ID < 1000" on the back. Query conditions resolved, if the sorting conditions are not clear?

We can spell the fixed section of SQL as: "SELECT * from Lccont where 1= 1 order 1=1" so we just need to append ", id" on the back.

Using this method to reduce repetitive and meaningless judgments can make the structure of the program clearer.

SQL Statement Stitching technique (reduces program bloat due to judging conditions)

Related Article

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.