anton zamov it expert logo    

home page latest news web development curriculum vitae scripts contact me

  • C# (Microsoft .NET)
  • JAVA
  • Dynamic HTML
  • PHP & MySQL
  • ASP.NET - C# & VB.NET
  • Perl & CGI
  • C | C++
  • Vector Markup Language
  • SMIL
  • Assembler
  • Databases
  • Wap Development
  • Web site promotion
  • Web Marketing



How to use regular expressions in MySQL database queries?

(Free programming example written by Anton Zamov.
Find more free examples on "The ultimate source for developers" )



One of the things I like the most in MySQL is
the possibility to use regular expressions in the SQL
queries.
 

A very simple example illustrating this is to select
all the records from MyTable for which MyField starts with "A"
 
SELECT * FROM  MyTable WHERE MyField REGEXP '^a';
 
Please take a look to the list below in order to find more information
for the available options
 

MySQL Regular Expressions
 


Matches zero or more instances of the string preceding it
 

Matches one or more instances of the string preceding it
 

Matches zero or one instances of the string preceding it
 

Matches any single character
 
[xyz] 
Matches any of x, y, or z (the characters within the brackets)
 
[A-Z] 
Matches any uppercase letter
 
[a-z] 
 Matches any lowercase letter
 
[0-9] 
Matches any digit
 

Anchors the match from the beginning
 

Anchors the match to the end
 

Separates strings in the regular expression
 
{n,m} 
String must occur at least n times, but no more than n 
 
{n} 
String must occur exactly n times
 
{n,| 
String must occur at least n times










Jobs Portal, poweful jobs board software

PHP Mall, multi vendors mall website software

Car Portal, php script for auto classifieds websites

NetArt Media, software products and services

Real Estate Portal, web software for real estate portals

Blog System, multi user blog hosting script

PHP Store, powerful e-commerce system written in PHP


C# (Microsoft .NET) | JAVA | Dynamic HTML | PHP & MySQL | Perl & CGI | C | C++ | Vector Markup Language
SMIL | Assembler | Databases | Wap Development | Web site promotion | Web Marketing

Copyright © Anton Zamov 1998 - 2023