A
A
archi19982014-07-06 13:50:16
PHP
archi1998, 2014-07-06 13:50:16

How to search for MULTIPLE words in the mysql database, regardless of the order, the length of the words is 1-4 letters?

How to search for MULTIPLE words in the mysql database, regardless of the order, the length of the words is 1-4 letters? For example, there is an entry aaa + bbb + ccc and the user enters ccc + aaa + bbb to find the entry, I wrote like
'% ccc% aaa% bbb%' but he does not find this entry because the order is wrong, maybe there is some construction in mysql so that the search is carried out without any order, do not iterate over all cases, thanks in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Morozov, 2014-07-06
@archi1998

WHERE (field_name LIKE %aaa% AND field_name LIKE %bbb% AND field_name LIKE %ccc%)

D
Dmitry Baibukhtin, 2014-07-15
@PiloTeZ

Use the regular expression REGEXP instead of LIKE, there will be many more possibilities, but also a load more

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question