Multi-field fuzzy match keyword Query

Source: Internet
Author: User
Fuzzy queries are often used when we develop database applications. What if the same condition needs to match many fields? Generally, ProgramEvery field is "field like % cond %" in SQL. In this way, SQL statements will grow astonishing, and even complex SQL statements will be refused to be executed by the database because of the excessive length.

In fact, this problem can be easily solved as long as you use your brains:

First, connect fields that match the same conditions (field1 + field2 +...) into a long string;
Then like "% cond %.

However, there is a problem with this method, that is, it is necessary to weigh the efficiency caused by multi-table join. In general, fields in a single table must be connected and then unified like judgment; For fields between tables, you must filter the fields before implementing this policy.

This policy can not only shorten SQL statements, but also effectively improve SQL Execution efficiency.

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.