Performing OR Matches Using REGEXP

To search for one of two strings either one or the other, use | as seen here:

SELECT prod_name
FROM products
WHERE prod_name REGEXP '1000|2000'
ORDER BY prod_name;

The above statement displayed the following output:

| prod_name    |
| product 1000 |
| product 2000 |

Here the regular expression 1000|2000 was used. | is the regular expression OR operator. It means match one or the other, and so both 1000 and 2000 matched and were returned.

Using | is functionally similar to using OR statements in SELECT statements, with multiple OR conditions being consolidated into a single regular expression.

More Than Two OR Conditions More than two OR conditions may be specified. For example, '1000|2000|3000' would match 1000 or 2000 or 3000.

by BrainBellupdated