MySQL single-table multi-field fuzzy query solving method

Source: Internet
Author: User
For example, existing table tables, which have title,tag,description three fields, record the title, label, and description of a piece of data, respectively. Then, based on the query request entered by the user, the input string is separated into several keywords through a space, and then the records containing these keywords are queried in these three fields. The problem is that these keywords are either one or more of the three fields, but require three fields to contain all the keywords. The MySQL authoritative guide has turned to the use of CONCAT in the book, the description of CONCAT is: CONCAT (str1,str2,...) Return value: The string that is obtained by merging all the access parameters together. Null is returned as long as there is a null value in the input parameter. Concat allows only one input parameter. Therefore, the preceding query can be implemented by the following SQL query
SELECT *  from WHERE  like '% keyword %'

MySQL single-table multi-field fuzzy query solving method

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.