Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ MySQL fuzzy query: LIKE and REGEXP pattern mode     - The wrong in Linux: too many open files (Linux)

- Java implementation chain store binary search tree (recursive method) (Programming)

- Configuring automatic mail GAMIT under CentOS system (Linux)

- How to configure AWStats in Ubuntu Server (Server)

- SQL Server 2008 database synchronization Notes (Database)

- Fedora 22 how to play rmvb mp4 mkv video files (Linux)

- Linux virtual machine settings network, hostname ssh access (Linux)

- Linux Demo dd IO test (Linux)

- MySQL innodb_table_stats table does not exist solution (Database)

- Install Python 3.3.4 under CentOS 6.4 (Linux)

- ORA-12547: TNS: lost contact error Solution (Database)

- Apache Kafka: the next generation of distributed messaging system (Server)

- ImportTsv-HBase data import tool (Database)

- To share Linux script automatically change passwords (Linux)

- php performance monitoring module XHProf (Linux)

- Linux Network Programming - raw socket instance: MAC Address Scanner (Programming)

- Netapp storage routine inspections and information gathering (Linux)

- Summarize small problems encountered in the use Lua (Programming)

- Ubuntu Linux to create and increase the Swap partition tutorial (Linux)

- GAMIT 10.50 installed in Ubuntu 12.04 system (Linux)

 
         
  MySQL fuzzy query: LIKE and REGEXP pattern mode
     
  Add Date : 2018-11-21      
         
         
         
  Fuzzy query MySQL offers two modes: LIKE and REGEXP pattern mode.

LIKE pattern

LIKE pattern is LIKE or NOT LIKE comparison operators using fuzzy query.

SELECT fields FROM table WHERE field LIKE [NOT LIKE] 'condition'
For conditions, the following wildcards:

Wildcard Meaning
% Represents any one or more characters, a character can match any type and length
_ Represents any single character matches any single character
ESCAPE keyword defines the escape character. In mode, when the escape character is placed before a wildcard, the wildcard is interpreted as ordinary characters.
 Example:

# Choose to live in "Ne" the beginning of the city from the "Persons" table people
SELECT * FROM Persons WHERE City LIKE 'Ne%'
# Selected people live in contains "lond" city from the "Persons" table
SELECT * FROM Persons WHERE City LIKE '% lond%'
# Select the name from "Persons" table after the first character is "eorge" people
SELECT * FROM Persons WHERE FirstName LIKE '_eorge'
# Selected from the "Persons" table Surname this record to "C" at the beginning, then any character, then "r", then any character, then "er"
SELECT * FROM Persons WHERE LastName LIKE 'C_r_er'
# Find "KPI" calculation table containing an index of 0%
SELECT * FROM KPI WHERE COUNT_PROCESS LIKE '% 0 / %%' ESCAPE '/'
note:

Wildcards must be used with the LIKE operator
If you do not use a wildcard, LIKE and = are equivalent
REGEXP pattern

REGEXP use REGEXP operator mode is for regular expression matching the query.

SELECT fields FROM table WHERE field REGEXP 'condition'
For conditions, the following wildcards:

Wildcard Meaning
^ Matches the beginning of the string. If you set the Multiline property of the RegExp object, ^ also matches '\ n' position or '\ r' after.
$ Matches the input end of the string. If you set the Multiline property RegExp object, also matching $ '\ n' or '\ r' position before.
Match except "\ n" any single character. To match including '\ n', including any characters, like the use of '[. \ N]' mode.
[...] Set of characters. Matches any character included. For example, '[abc]' matches "plain" in the 'a'.
[^ ...] Negative character set. Matches any character that is not included. For example, '[^ abc]' matches "plain" in the 'p'.
p1 | p2 | p3 match p1, p2, or p3. For example, 'z | food' can match the "z" or "food". '(Z | f) ood' will match "zood" or "food".
* Matches the preceding subexpression zero or more times. For example, zo * can match the "z" and "zoo". * Equivalent to {0,}.
+ Match the preceding subexpression one or more times. For example, 'zo +' will match "zo" and "zoo", but can not match the "z". + Is equivalent to {1}.
{N} n is a non-negative integer. Matching the determined n times. For example, 'o {2}' does not match the "Bob" in the 'o', but can match the "food" in the two o.
{N, m} m and n are non-negative integers, where n <= m. Match at least n times and match up to m times.
Example:

# Find the name field, all data 'st' beginning with:
SELECT name FROM person_tbl WHERE name REGEXP '^ st';
# Find the name field, all data is 'ok' for the ending:
SELECT name FROM person_tbl WHERE name REGEXP 'ok $';
# Find the name field contains 'mar' string of all data:
SELECT name FROM person_tbl WHERE name REGEXP 'mar';
# Find the name field to begin with vowels and with 'ok' end of the string of all data:
SELECT name FROM person_tbl WHERE name REGEXP '^ [aeiou] | ok $';
     
         
         
         
  More:      
 
- To achieve Linux Security (Linux)
- php performance monitoring module XHProf (Linux)
- Ubuntu / Fedora / CentOS system how to install Plex Media Server 0.9.9 (Linux)
- Shell array: Define Shell array, the array length (Programming)
- Analysis of potential problems through custom Orabbix monitoring Oracle (Database)
- Transplant spider to MySQL 5.6 (Database)
- Compile and install Ubuntu Linux 4.0.5 kernel, network and fix vmware kernel module compilation error (Linux)
- OpenGL Superb Learning Notes - Vertex Shader example (Programming)
- How the program is executed (Programming)
- RedHat Linux 9.0 under P4VP-MX motherboard graphics resolution of problems (Linux)
- OpenStack package problems and solutions under CentOS6 (Linux)
- Ubuntu Live CD by updating Grub resume boot the Boot Menu (Linux)
- How to use Java to read OpenOffice document (Programming)
- CentOS 6 adds disk quota limit (Linux)
- Oracle Standby Redo Log experiment (Database)
- To get Java class / jar package path (Programming)
- Local port forwarding using iptables under linux (Server)
- How to use GRUB2 files directly from the hard disk to run ISO (Linux)
- 10 easy to use Linux utilities Recommended (Linux)
- Hadoop new and old version of the difference in the size of the InputSplit (Server)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.