TIME NOW
World current time now,
CALENDAR
Calendar monthly, yearly
login CONVERT LENGTH
login CONVERT TEMPERATURE
login DICTIONARIES, LISTS
login SCIENCE EDUCATION RELIGION
login WORK CALCULATOR
login CALCULATE LIFE

MYSQL dabatase. How to, tutorial, examples

Previous articlePage bottomNext article  ALL TOPICS

Mysql. select query example: where regexp regular expressions

 
SELECT  REGEXP
SELECT something FROM table WHERE column REGEXP 'regexp'

For example, to select all columns from the table events where the values in the column id end with 5587, use:
SELECT * FROM events WHERE id REGEXP '5587$'
 
SELECT *
FROM t_songs
WHERE BINARY(  `text` )
REGEXP  '^[[:lower:]]'
LIMIT 0 , 30

A more elaborate example selects all columns of the table reviews where the values in the column description contain the word excellent:
SELECT * FROM reviews WHERE description REGEXP '[[:<:]]excellent[[:>:]]'
REGULAR EXPRESSIONS

.match any character
? match zero or one
* match zero or more
+ match one or more
{n} match n times
{m,n} match m through n times
{n,} match n or more times
^ beginning of line
$ end of line
[[:<:]] match beginning of words
[[:>:]] match ending of words
[abc] match one of enclosed chars
[^xyz] match any char not enclosed
| separates alternatives
[:class:] match a character class
[[:alnum:]]    Alphanumeric - any number or letter. Equivalent to [a-z], [A-Z] and [0-9]
[[:alpha:]]    Alpha - any letter. Equivalent to [a-z] and [A-Z]
[[:blank:]]    Space or Tab. Equivalent to [\\t] and [ ]
[[:cntrl:]]    ASCII Control Character
[[:digit:]]    Numeric. Equivalent to [0-9]
[[:graph:]]    Any character with the exception of space
[[:lower:]]    Lower case letters. Equivalent to [a-z]
[[:print:]]    Any printable character
[[:punct:]]    Characters that are neither control characters, nor alphanumeric (i.e punctuation characters)
[[:space:]]    Any whitespace character (tab, new line, form feed, space etc)
[[:upper:]]    Upper case letters. Equivalent to [A-Z]
[[:xdigit:]]    Any hexadecimal digit. Equivalent to [A-F], [a-f] and [0-9]

  
Previous articlePage topNext article  ALL TOPICS



 Use username: Guest, Anonymous, Programmer






QUOTES:
In the attitude of silence the soul finds the path in an clearer light, and what is elusive and deceptive resolves itself into crystal clearness. Our life is a long and arduous quest after Truth.
Mahatma Gandhi
A benevolent man should allow a few faults in himself, to keep his friends in countenance.
Benjamin Franklin
I pretend to work they pretend to pay me!
Mimi