Reputation: 2036
I have a table like this:
country (id, name)
I want to find the id where for example the search string is "Russian Federation" and in my table is stored the value "Russia".
Pratically the stored value is a substring of the search string.
Upvotes: 1
Views: 385
Reputation: 1269493
If that is the case, then you can do:
select *
from country
where concat(' ', SEARCHSTRING, ' ') like concat('% ', name, ' %')
Or you can use find_in_set()
:
select *
from country
where find_in_set(name, replace(SEARCHSTRING, ' ', ',')) > 0;
Upvotes: 1
Reputation: 3659
You can try it like this:
SELECT *
FROM Country
WHERE 'Russian Federation' LIKE CONCAT('%', Name, '%')
Here's the SQL Fiddle Demo.
Upvotes: 4