0

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

SQB
  • 3,926
  • 2
  • 28
  • 49
directory
  • 3,093
  • 8
  • 45
  • 85
  • Possible duplicate of [MySQL: What is a reverse version of LIKE?](http://stackoverflow.com/questions/472063/mysql-what-is-a-reverse-version-of-like) – joshweir Mar 24 '16 at 03:52

1 Answers1

5
SELECT *
FROM   tableName
WHERE  'the animal is a fox' LIKE CONCAT('%', animal ,'%')
John Woo
  • 258,903
  • 69
  • 498
  • 492
  • 1
    I have a large database that I want to do something similar with, but only if it remains indexed. If I format it like: WHERE 'the animal is a fox' LIKE CONCAT(animal ,'%') will it use the index on animal please? – user2605793 Apr 17 '14 at 07:53