Regular expression to match a string in MySQL
mysql, regex
Solution
You cannot use CONCAT or alike with REGEX, it will fail. Easiest way to do it, is:
$query = 'SELECT * FROM Test WHERE colb REGEXP "^'.substr($mystring,0,3).'"');
Another is:
SELECT * FROM Test WHERE LEFT(colb, 3) LIKE "{$mystring}%"
Problem
How to write a regular expression to match a string if at least 3 characters from the start are matching? Here is how my MySQL query looks right now - ``` SELECT * FROM tableName WHERE columnName REGEXP "^[a-zA-Z]{3}someString"; ```