Learning about MOOC php fuzzy search technology

Source: Internet
Author: User
Learning MOOC php fuzzy query technology ①. database design
If the password is md5, char (32) is used. if the password stores half of the data, char is used.
Gender. int is used for normal development.
Input condition, with default setting default value
Key indicates adding an index, which indicates an index to the resume of a specified field.
The benefit of indexing: if data is retrieved based on a condition and no index is created for this condition field, the entire table will be traversed during the query. if you create an index, the query results are indexed to improve the query performance.

②. Considerations for the SQL matching mode
1. use the SQL matching mode. the operator = OR! is not allowed! =
Instead, use the like or not like operator.
2. Using the SQL matching mode, mysql provides two wildcards.
% (Percent): represents any number of arbitrary characters
_ (Underline): represents any single character
3. use the mysql matching mode. if the matching format does not contain any of the above two wildcards,
The query result is equivalent to = OR! =
4. the SQL matching mode is case insensitive by default.

③.
Use wildcards;
0. case insensitive by default
1. start or end with %.
2.% contains.
3. start or end with _ %
3. Length _.

④ Regular expression match character
. MatchAny single character
* Match0 or more characters before it
A * indicates matching any number of a characters
[..] Matching any character in brackets
[Abc] matching characters a B or c
[A-z] matches any character
[0-9] match any number
[0-9] * match any number
[A-z] * matches any number of characters
^ IndicatesStart with a character or string
^ A starts with.
$ IndicatesEnd of a character or string
A $ indicates ending with letter

⑤ Operators used in regular expression matching mode
1. regexp or not regexp; (RLIKE or not rlike)
If a regular expression is used for matching, the mode is different from the SQL mode.
SQL statement select * from user where username REGEXP 'Reg ';

Differences between regular expressions and SQL matching modes

To obtain a field with several characters, you need to add the start and end symbols. Otherwise, there will be several wildcards. you just need to go back and determine which number is better.

Error_reporting (0); all errors are blocked. it is not recommended during development and can be listed on the market.

$ Row ['username'] = str_replace ($ keywords, "". $ keywords. "", $ row ['username']); // keyword highlighting

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.