0

I would like to make a research in a mysql database with several word machting word OR subword

for instance if I search for "ata" I want to obtain "data" and "database" if I search for "ata" and "get" I want to obtain "database is getting"

For the moment I use 2 times LIKE function:

SELECT col FROM mytable WHERE col LIKE "%ata%"

and then

SELECT col FROM mytable WHERE col LIKE "%get%"

if work but I think there is a more efficient way to that.

I tried:

SELECT col FROM mytable WHERE MATCH (col) AGAINST (concat('%','ata get','%') IN BOOLEAN MODE)

but it does not work.

If there a solution using MACH AGAINST?

1 Answer 1

1

Why don't you just use and in your original query?

SELECT col
FROM mytable
WHERE col LIKE "%ata%" and col like col LIKE "%get%"

Or, you can combine them into one expression if you care about the order of the matches:

select col
from mytable
where col like '%ata%get%'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.