parliament
parliament

Reputation: 22914

Text search when already using WHERE IN clause

I'm looking for a way to perform a text-search similar to SQL LIKE clause, when already using a WHERE IN clause.

I tried something like:

SELECT DISTINCT name FROM cars 
WHERE driverName IN ("Bob", "Joe")
MATCH(name) AGAINST ('"mercedez"' IN BOOLEAN MODE)

But I can't get a working query based on the text-search term "mercedez"

Upvotes: 0

Views: 31

Answers (1)

Veve
Veve

Reputation: 6758

If you want to get the names of cars with "mercedez" in it AND drived by "Bob" or "Joe", you can add an AND clause with wildcards (in case the name of the car contains other things than "mercedez"):

SELECT DISTINCT name FROM cars 
WHERE driverName IN ("Bob", "Joe")
AND name LIKE "%mercedez%";

If you want to get the names of cars with "mercedez" in it OR drived by "Bob" or "Joe", add an OR clause:

SELECT DISTINCT name FROM cars 
WHERE driverName IN ("Bob", "Joe")
OR name LIKE "%mercedez%";

Upvotes: 1

Related Questions