A PHP Error was encountered

Severity: 8192

Message: str_replace(): Passing null to parameter #3 ($subject) of type array|string is deprecated

Filename: libraries/Filtered_db.php

Line Number: 23

Write a mysql statement to retrieve name beginning with 'm'
Q:

Write a mysql statement to retrieve name beginning with 'm'

0

Write a mysql statement to retrieve name beginning with 'm'

Suppose the table is -

+----+--------------+------------+------------+
| id | name         | department | birth      |
+----+--------------+------------+------------+
|  1 | Maria Gloria | CS         | 1994-03-12 |
|  2 | John Smith   | IT         | 1993-02-07 |
|  3 | Gal Rao      | CS         | 1992-09-11 |
|  4 | Jakey Smith  | EC         | 1990-08-31 |
|  5 | Rama Saho    | IT         | 1994-12-09 |
|  6 | Maria Gaga   | EC         | 1993-10-09 |
+----+--------------+------------+------------+

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Solution

To apply extended regular expression, REGEXP operator is used with pattern matching characters.
To find names beginning with 'm', use ^ to match the beginning of the name. It returns 1 if the string expr matches the regular expression specified by the pattern 'm', 0 otherwise.

mysql> SELECT * FROM students
     -> WHERE name REGEXP '^m';

Output of the above statement -

+----+--------------+------------+------------+
| id | name         | department | birth      |
+----+--------------+------------+------------+
|  1 | Maria Gloria | CS         | 1994-03-12 |
|  6 | Maria Gaga   | EC         | 1993-10-09 |
+----+--------------+------------+------------+

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now