directory
directory

Reputation: 3167

Mysql like search in reverse

I don't know if my title is telling exactly the right thing what I try to do but so on here an example of course.

e.g.

I have a database with the fields id | animal | population ... It's all about the animal field. I have a string like 'the animal is a fox', or 'the fox is brown'.

I would like to pass this string through a mysql query which will return me 'fox' as a match.

Thank you in advance!

Nick

Upvotes: 0

Views: 1831

Answers (1)

John Woo
John Woo

Reputation: 263943

SELECT *
FROM   tableName
WHERE  'the animal is a fox' LIKE CONCAT('%', animal ,'%')

Upvotes: 5

Related Questions