Details
-
Type: Improvement
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 3.4.8, 4.0.8, 4.1.0
-
Fix Version/s: 4.2.0
-
Component/s: CiviCRM Search
-
Labels:None
Description
RLIKE is a very useful MySQL operator that allows regular expression matches on fields. One use case that came up recently was a request to search for contacts in ZIP code prefixes 940,941,942,943,944,949 (but not 945,946,947,948).
With the regular LIKE operator, this is a rather tedious Search Builder query with five "Also include..." clauses:
LIKE 940%
LIKE 941%
LIKE 942%
LIKE 943%
LIKE 944%
LIKE 949%
With RLIKE, we can use a single clause with a simple regex to match just the required prefixes:
RLIKE 94[012349]..
I'm sure there are many other use cases, and it's a simple change to CRM/Core/BAO/Mapping.php