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.