Retrieving Information from a Table | Fluffy | Harold | cat | f | 1993-02-04 | NULL | | Buffy | Harold | dog | f | 1989-05-13 | NULL | +--------+--------+---------+------+------------+-------+ mysql>  SELECT * FROM pet WHERE name LIKE ’%w%’; +----------+-------+---------+------+------------+------------+ | name | owner | species | sex | birth | death | +----------+-------+---------+------+------------+------------+ | Claws | Gwen | cat | m | 1994-03-17 | NULL | | Bowser | Diane | dog | m | 1989-08-31 | 1995-07-29 | | Whistler | Gwen | bird | NULL | 1997-12-09 | NULL | +----------+-------+---------+------+------------+------------+ mysql>  SELECT * FROM pet WHERE name LIKE ’_____’; +-------+--------+---------+------+------------+-------+ | name | owner | species | sex | birth | death | +-------+--------+---------+------+------------+-------+ | Claws | Gwen | cat | m | 1994-03-17 | NULL | | Buffy | Harold | dog | f | 1989-05-13 | NULL | +-------+--------+---------+------+------------+-------+ mysql>  SELECT * FROM pet WHERE REGEXP_LIKE(name, ’^b’); +--------+--------+---------+------+------------+------------+ | name | owner | species | sex | birth | death | +--------+--------+---------+------+------------+------------+ | Buffy | Harold | dog | f | 1989-05-13 | NULL | | Bowser | Diane | dog | m | 1979-08-31 | 1995-07-29 | +--------+--------+---------+------+------------+------------+ 320 To force a regular expression comparison to be case-sensitive, use a case-sensitive collation, or use the BINARY  keyword to make one of the strings a binary string, or specify the  c  match-control character. Each of these queries matches only lowercase  b  at the beginning of a name: To find names beginning with  b , use  ^  to match the beginning of the name: To demonstrate how extended regular expressions work, the  LIKE  queries shown previously are rewritten here to use  REGEXP_LIKE() . The other type of pattern matching provided by MySQL uses extended regular expressions. When you test for a match for this type of pattern, use the  REGEXP_LIKE()  function (or the  REGEXP  or  RLIKE  operators, which are synonyms for  REGEXP_LIKE() ). •To anchor a pattern so that it must match the beginning or end of the value being tested, use  ^  at the beginning or  $  at the end of the pattern. •A regular expression pattern match succeeds if the pattern matches anywhere in the value being tested. (This differs from a  LIKE  pattern match, which succeeds only if the pattern matches the entire value.) • *  matches zero or more instances of the thing preceding it. For example,  x*  matches any number of  x characters,  [0-9]*  matches any number of digits, and  .*  matches any number of anything. •A character class  [...]  matches any character within the brackets. For example,  [abc]  matches  a ,  b , or  c . To name a range of characters, use a dash.  [a-z]  matches any letter, whereas  [0-9]  matches any digit. • .  matches any single character. The following list describes some characteristics of extended regular expressions: To find names containing exactly five characters, use five instances of the  _  pattern character: To find names containing a  w :