MySQL Reg ex, you need to combine phrases in any order

I am using a MySQL database to search through a list of categories. My request:

select * from cat, where the name is REGEXP ('(region_Long Island) + (.) * (sport_Outdoor Track)');

where the values ​​of "region_Long Island" and "sport_Outdoor Track" are passed. I need to be able to match these categories, regardless of the order in which they are. In the table, it is possible to have various combinations of these two categories. I need to match any entries that have both of these categories, regardless of the order in which they are listed.

I can’t change the request itself, just change what is passed to the REGEXP function.

thank

+3
source share
2

, SQL-, A, B , AB BA:

'region_Long Island.*sport_Outdoor Track|sport_Outdoor Track.*region_Long Island'

:

, , - ?

A, B C, , , ABC, ACB, CAB, CBA, BAC BCA. , n! , n .

. .

, , REGEXP.

, .

+2
SELECT  *
FROM    cat
WHERE   name RLIKE 'region_Long Island'
        AND name RLIKE 'sport_Outdoor Track'
0

Source: https://habr.com/ru/post/1763858/


All Articles