Query:
SELECT * FROM (test) test_label WHERE REGEXP "AA(.*)BB" OR test_label REGEXP "BB(.*)AA"**
Database (string):
1. AA BB 100
2. AA BB 200
3. BB AA 300
4. BB CC 100
5. AA CC 300
This query returns rows: 1, 2 and 3.
How:
Combine this expression into one (but - i want it with one REGEXP but not with OR - if it is possible it must not take order of input vars and i don't must search for all possible combinations)
Now if query is "AA BB" i must find all possible cases - in this case it's only:
- AA(.)BB|BB(.)AA
but if query is "AA BB CC" it is a lot more cases.
Test cases:
- query "AA BB" returns rows 1,2,3.
- query "BB 300" return only row 3.
- query "BB CC 100" return only row 4.
- query "BB 100" return rows 1,4.