Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ MySQL fuzzy query: LIKE and REGEXP pattern mode     - Lua4.0 interpreter documents (Programming)

- Based on Google Cloud Storage Mirroring open Maven Central Repository (Server)

- About Linux operating system security (Linux)

- Ubuntu 14.04 installed NVIDIA graphics driver (Linux)

- How to configure chroot environment in Ubuntu 14.04 (Linux)

- Ubuntu manually set the DSL broadband connection (Linux)

- apt-get install openstack pkg Troubleshooting (Linux)

- Ubuntu system cp: omitting directory problem (Linux)

- Linux fixes fatal error: x264.h: No such file or directo (Linux)

- Linux under HAProxy + Keepalived dual-availability program (Server)

- Three details reflect the Unix system security (Linux)

- Learn to read the source code of vmstat (Linux)

- Oracle data row split multiple lines (Database)

- CentOS-based Kickstart automated installation practice (Linux)

- Linux common network tools: batch scanning of hosting services netcat (Linux)

- Linux hard drive failure Case Studies (Linux)

- Proper use Core Data multithreaded 3 ways (Programming)

- Turning off the interface eth0: error: Disconnect the device 'eth0' (Linux)

- Linux system installation and usage instructions Wetty (Linux)

- MySQL database to open a remote connection method (Database)

 
         
  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:      
 
- Android Studio Getting Started Hello World (Programming)
- Pydev installed and configured on the Eclipse (Linux)
- Java Virtual Machine Basics (Programming)
- Nginx concerning the location and rewrite applications proxy_pass (Server)
- Use Python to perform system commands common usage (Programming)
- VMware Workstation virtual machine startup error: Could not open / dev / vmmon in CentOS 6 (Linux)
- Error: Unable to establish connection with FTP SFTP server (Server)
- Android memory optimization of the disk cache (Linux)
- To record command input under Linux (Linux)
- Some security configuration of Linux systems (Linux)
- Oracle SDE and maintain common commands - Display space (Database)
- CentOS7 Kubernetes used on container management (Server)
- Fedora 20 users install the Mate 1.8 desktop (Linux)
- Linux system with a firewall to prevent the DOS attack (Linux)
- Reason C ++ program running under Linux a segmentation fault core dumped in (Programming)
- HttpClient4 usage upgrade from HttpClient3 (Programming)
- Traffic monitor Linux Python Version (Programming)
- QEMU image file used: qcow2 and raw (Linux)
- SLF4J Tutorial (Programming)
- Build Eclipse + Maven + Scala-IDEA the Scala Web development environment (Server)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.