How can I split words during search and query? -Php Tutorial

Source: Internet
Author: User
Tags split words
How can I split words during search and query? For example
Product title
Field title
Autumn and Winter new large women's loose sweater coat female cardigan thickened long wool
Product comments
Field content
In autumn and winter, the room is comfortable to wear and the cotton-padded vest is also fashionable. A-shaped skirt model can block waist and abdomen. Shoulder bearing gravity is worth upgrading and improving in weaving design. The sleeve cage is narrow and thin, and the sleeve length is short. the materials are cool compared with the width of the body. The lining can only be paired with a sleeveless or slim shirt. I am 159, 135g, 103cm bust, 39cm shoulder width, 35cm arm circumference, for reference. Very worried about shrinkage rate, lest the baby is "water clothing ".


Search for large-size wool jackets

Search for large-size wool comfort models

How can we achieve this? what kind of thinking should I start to think about? '%'. $ wd. '%' of a keyword '? That would not enable the simultaneous appearance of several words.



Reply to discussion (solution)

MySQL provides regular expression search. why not use it?

$ Word = 'large-size wool coat '; $ word = preg_replace ('/\ s +/',' | ', trim ($ word )); $ SQL = "select * from tbl_name where concat (title, content) REGEXP '$ word '";

If conditions permit, the use of third-party full-text retrieval is much more efficient.

At the same time, it is not easy to do because of order problems.
Although large size. * wool is a way
But does wool. * Is it possible for large size?

MySQL's regular expressions are relatively simple. such expressions as php are not supported.

$ S = 'Autumn and winter new large women's loose sweater coat female cardigan padded long wool '; $ p = '/(? =. * Wool )(? =. * Large size). */'; echo preg_match ($ p, $ s); // 1 matched successfully


It was intended to be simple, and it would be boring if it was complicated.

At the same time, it is not easy to do because of order problems.
Although large size. * wool is a way
But does wool. * Is it possible for large size?

MySQL's regular expressions are relatively simple. such expressions as php are not supported.

$ S = 'Autumn and winter new large women's loose sweater coat female cardigan padded long wool '; $ p = '/(? =. * Wool )(? =. * Large size). */'; echo preg_match ($ p, $ s); // 1 matched successfully


It was intended to be simple, and it would be boring if it was complicated.



Why did the query time soar from 0.3 to 1.8 after I added the ID sorting? is there a solution?

At the same time, it is not easy to do because of order problems.
Although large size. * wool is a way
But does wool. * Is it possible for large size?

MySQL's regular expressions are relatively simple. such expressions as php are not supported.

$ S = 'Autumn and winter new large women's loose sweater coat female cardigan padded long wool '; $ p = '/(? =. * Wool )(? =. * Large size). */'; echo preg_match ($ p, $ s); // 1 matched successfully


It was intended to be simple, and it would be boring if it was complicated.



I sorted 13 pieces of data in 0.4 seconds at a lower speed. why is it slower to sort by ID?

I learned

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.