mysql: like multiple values

if you for example if you want to make a query to select various text values using the "LIKE" operator for example:

SELECT
*
FROM
animals
where
animal_name like '%dog%'
or animal_name like '%cat%'
or animal_name like '%cow%'

 

you can summarize that query using the following:

SELECT
*
FROM
animals
where
animal_name REGEXP 'dog|cat|cow'

Leave a Reply

Your email address will not be published. Required fields are marked *