Reputation: 23
Is there a way to use the like statement in MYSQL without the order mattering? For example:
WHERE Country LIKE '%land1%land2%';
and
WHERE Country LIKE '%land2%land1%';
are two completely different statements. While the first one only gets data from rows that contains the words land1, and land2 in that specific order, the second one only gets data from rows that contains the words land2, and land1 in that specific order. Is there a way to bypass this?
Upvotes: 1
Views: 418
Reputation: 2500
WHERE Country REGEXP 'land1|land2';
Which will be output as same as:
WHERE (Country LIKE '%land1%' OR Country LIKE '%land2%');
Upvotes: 0
Reputation: 33883
Use an AND
boolean operator with two independent LIKE
clauses.
WHERE Country LIKE '%land2' AND Country LIKE '%land1%';
Upvotes: 2